如何在swift中添加左上角的曲线视图
如何使用曲线将uiview添加到左上角 我做过类似的事情如何在swift中添加左上角的曲线视图,swift,uiviewanimation,uibezierpath,cgpoint,Swift,Uiviewanimation,Uibezierpath,Cgpoint,如何使用曲线将uiview添加到左上角 我做过类似的事情 class curvedView: UIView { override func draw(_ rect: CGRect) { let color = UIColor.blue let y:CGFloat = 0 let myBezier = UIBezierPath() myBezier.move(to: CGPoint(x: 0, y: y))
class curvedView: UIView {
override func draw(_ rect: CGRect) {
let color = UIColor.blue
let y:CGFloat = 0
let myBezier = UIBezierPath()
myBezier.move(to: CGPoint(x: 0, y: y))
myBezier.addQuadCurve(to: CGPoint(x: rect.width, y: y), controlPoint: CGPoint(x: rect.width / 2, y: rect.height * 2))
myBezier.addLine(to: CGPoint(x: rect.width, y: rect.height))
myBezier.addLine(to: CGPoint(x: 0, y: rect.height))
myBezier.close()
color.setFill()
myBezier.fill()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = UIColor.clear
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.backgroundColor = UIColor.clear
}
}
但这将创建一条U形曲线,但我需要从x位置180到Y位置250的曲线
任何帮助都是非常感激的 你可以试试这些代码。它会帮你的
let path = UIBezierPath(roundedRect:viewToRound.bounds, byRoundingCorners:[.TopRight, .BottomLeft], cornerRadii: CGSizeMake(20, 20))
let maskLayer = CAShapeLayer()
maskLayer.path = path.CGPath
viewToRound.layer.mask = maskLayer
你到底想要什么?您是否有所需输出的渲染?还有,你当前的代码是什么样子的?@Larme我无法上传任何图片来显示。谢谢你的回复,但这对我没有帮助。