두 개의보기가 서로 쌓여 있습니다. 보기 B가 더 큰보기 A 위에 쌓인다고 가정 해 봅시다.보기 B는 원형이며 더 큰보기 A가 접촉을 받아 들여야하는 대신 원의 바깥 부분을 받아 들여서는 안됩니다.원형 UIView가 원형 바깥에있는 접촉을 인식하지 못하게하는 방법은 무엇입니까?
나는 그것이 원형 경로와-있는지 확인하고이 같은 인식기 슈퍼에 취소 접촉 전화 뷰 B의 사용자 지정 PanGesture 인식기의 touchesBegan 메서드를 재정 시도했다 :
override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
let touch = touches.anyObject() as UITouch
let location = touch.locationInView(self.view)
let isInPath = self.path.containsPoint(location)
if(isInPath){
super.touchesBegan(touches, withEvent: event)
self.rotation = rotationForLocation(location)
}else{
// touch started outside of path so cancel touch
super.cancelsTouchesInView = true
super.touchesCancelled(touches, withEvent: event)
}
}
그것을 보기 B가 원형 경로 외부의 접촉을 허용하지 않지만보기 A는 해당 접촉을 허용하지 않습니다. 어떤 도움을 주셔서 감사합니다, 감사합니다.
hitTest 메서드를 재정의하십시오. – rmaddy