I’ve created a view like this utilizing XIB with having half of top assign to that view.
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.top - cornerRadius)
let left = CGPoint(x: cornerRadius, y: goal.bounds.top / 2)
// Offset for easy 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()
// 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 aspect down, which give me end result like under.
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 prohibit contact occasions outdoors that picture like under picture. I’ve the place it is taking full view width and top for that picture.
any assist could be appreciated.