HomeiOS Developmentios - Limit consumer contact occasions outdoors drawn bezierpath

ios – Limit consumer contact occasions outdoors drawn bezierpath


I’ve created a view like this utilizing XIB with having half of peak 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 aspect
        let high = CGPoint(x: goal.bounds.width - cornerRadius, y: cornerRadius)
        let backside = CGPoint(x: goal.bounds.width - cornerRadius, y: goal.bounds.peak - cornerRadius)
        let left = CGPoint(x: cornerRadius, y: goal.bounds.peak / 2)
        
        // Offset for clean curves
        let offset = cornerRadius / 2
        
        // Begin from high -> backside
        path.transfer(to: CGPoint(x: high.x, y: high.y + offset))
        path.addQuadCurve(to: CGPoint(x: backside.x, y: backside.y - offset),
                          controlPoint: high)
        
        // Backside -> left (center)
        path.addQuadCurve(to: CGPoint(x: left.x + offset, y: left.y),
                          controlPoint: backside)
        
        // Left -> again to high
        path.addQuadCurve(to: CGPoint(x: high.x, y: high.y + offset),
                          controlPoint: left)
        
        path.shut()
        
        // Fashion
        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 aspect down, which give me outcome like beneath.

image2

This picture has pan gesture added nevertheless it;s taking full view width and peak. It isn’t contemplating drawn path on this view.

I need to prohibit contact occasions outdoors that picture like beneath picture. I’ve the place it is taking full view width and peak for that picture.

any assist could be appreciated.

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments