ios – Prohibit person contact occasions exterior drawn bezierpath

0
6
ios – Prohibit person contact occasions exterior drawn bezierpath


I’ve created a view like this utilizing XIB with having half of top assign to that view.

image

static func drawRightTriangle(targetView goal: UIView, cornerRadius: CGFloat, borderView: UIView) {
        
        // Create a brand new path
        let path = UIBezierPath()
        
        // Triangle factors for proper facet
        let prime = CGPoint(x: goal.bounds.width - cornerRadius, y: cornerRadius)
        let backside = CGPoint(x: goal.bounds.width - cornerRadius, y: goal.bounds.top - cornerRadius)
        let left = CGPoint(x: cornerRadius, y: goal.bounds.top / 2)
        
        // Offset for easy curves
        let offset = cornerRadius / 2
        
        // Begin from prime -> backside
        path.transfer(to: CGPoint(x: prime.x, y: prime.y + offset))
        path.addQuadCurve(to: CGPoint(x: backside.x, y: backside.y - offset),
                          controlPoint: prime)
        
        // Backside -> left (center)
        path.addQuadCurve(to: CGPoint(x: left.x + offset, y: left.y),
                          controlPoint: backside)
        
        // Left -> again to prime
        path.addQuadCurve(to: CGPoint(x: prime.x, y: prime.y + offset),
                          controlPoint: left)
        
        path.shut()
        
        // Model
        UIColor.darkGray.setStroke()
        path.lineWidth = 4
        path.lineJoinStyle = .spherical
        path.stroke()
        
        // Create a CAShapeLayer
        let shapeLayer = CAShapeLayer()
        shapeLayer.path = path.cgPath
        shapeLayer.place = CGPoint(x: 0, y: 0)
        goal.layer.masks = shapeLayer
        
        // 2. Add border layer (stroke solely)
        let borderLayer = CAShapeLayer()
        borderLayer.path = path.cgPath
        borderLayer.strokeColor = UIColor.white.cgColor
        borderLayer.fillColor = UIColor.clear.cgColor
        borderLayer.lineWidth = 0
        borderLayer.body = goal.bounds

        // 3. Add stroke layer as sublayer (not affected by masks)
        goal.layer.addSublayer(borderLayer)
    }

Above code is to attract triangle from up facet down, which give me consequence like beneath.

image2

This picture has pan gesture added however it;s taking full view width and top. It is not contemplating drawn path on this view.

I wish to limit contact occasions exterior that picture like beneath picture. I’ve the place it is taking full view width and top for that picture.

any assist could be appreciated.

enter image description here

LEAVE A REPLY

Please enter your comment!
Please enter your name here