我使用UIViewUIBezierPath设置了setCornerRadius拐角半径。检查以下代码:

func roundCorners(cornerRadius: Double) {
        let path = UIBezierPath(roundedRect: self.puttingView.bounds, byRoundingCorners: [.topLeft, .topRight, .bottomLeft, .bottomRight], cornerRadii: CGSize(width: cornerRadius, height: cornerRadius))
        let maskLayer = CAShapeLayer()
        maskLayer.frame = self.puttingView.bounds
        maskLayer.path = path.cgPath
        self.puttingView.layer.mask = maskLayer
    }

现在,当我试图单击“外部”角半径时,我正在将UITapGestureRecognizer设置为UIView,并且可以单击UIView
所以我不想得到外角半径。

最佳答案

试试这个:

@objc func tapped(_ gesture: UITapGestureRecognizer) {
        let loc:CGPoint = gesture.location(in: gesture.view)
        if let layer = puttingView.layer.mask, layer.bounds.contains(loc){
            print("inside")
        }
    }

关于ios - 如何在iOS的圆形UIView中获取CGPoint?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56847494/

10-12 00:40
查看更多