UIView에서 BezierPaths 내부의 탭을 감지하려고하고 containsPoint 메소드에 대한 많은 참조를 발견했습니다. 그러나 실제로 내 ViewController에서 BezierPaths를 참조하는 방법을 찾을 수없는 것 같습니다.UIView에서 BezierPath를 참조하는 방법
I가 설정 :
class func drawSA(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 69, height: 107), resizing: ResizingBehavior = .aspectFit, SACountries: [String: ViewController.CountryStruct])
{
let myPath = UIBezierPath()
myPath.move(to: CGPoint(x: 32.24, y: 8.61))
myPath.addLine(to: CGPoint(x: 31.99, y: 8.29))
myPath.addLine(to: CGPoint(x: 31.78, y: 8.19))
myPath.close()
}
베지이 함수에 그려, 호출 : 메인의 ViewController에서
override func draw(_ rect: CGRect)
, I는 상기에 탭을 검출하는 기능에 따라 한 UIView :
@objc func SATap(sender: UITapGestureRecognizer)
{
let location = sender.location(in: self.SAView)
// how do I call containsPoint from here?
}
여기에서 containsPoint를 어떻게 호출합니까?
bezierPaths는 런타임에 올바르게 그려집니다.
경로를보기의 속성으로 저장하십시오. 'self.SAView.myPath'로 containsPath를 호출합니다. – Larme