【发布时间】:2020-01-27 14:39:33
【问题描述】:
我画了三角形,但在情节提要上看不到。我怎样才能在故事板上看到这幅画?
class ViewController: UIViewController {
@IBOutlet weak var fooView: UIView!
var polygonShape = CAShapeLayer()
override func viewDidLoad() {
super.viewDidLoad()
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 50, y: -1))
polygonPath.addLine(to: CGPoint(x: 93.3, y: 74))
polygonPath.addLine(to: CGPoint(x: 6.7, y: 74))
polygonPath.close()
polygonShape.frame = fooView.bounds
polygonShape.path = polygonPath.cgPath
fooView.layer.mask = polygonShape
}
}
【问题讨论】:
-
你想要一个向上的三角形吗?
-
是的,先生。我想在故事板上看图画
标签: ios swift xcode uibezierpath cashapelayer