jjzjj

shapeMask

全部标签

ios - 形状像 UIBezierPath 的 UIView?

在iOS上是否可以在某些CGRect中创建一个常规的UIView并向其添加subview,然后像这样告诉容器UIView:containerView.layer.path=someClosedUIBezierPath?然后所有的subview也会根据它的父容器View弯曲吗?我知道每个UIView都有自己的CALayer,这将是我的起点。我看到了带有动画的例子,但我没有看到像上面那样的东西(可能是因为它不存在:)) 最佳答案 这有点晚了,但也许它会对某人有所帮助:您可以使用CAShapeLayer和View层的mask属性将View

ios - 将渐变应用于虚线 UIBezierPath

这个渐变是我想在虚线UIBezierPath上实现的。试过这段代码没有成功。letgradient=CAGradientLayer()gradient.frame=outerPath.boundsgradient.colors=[UIColor.red.cgColor,UIColor.yellow.cgColor]//maskletshapeMask=CAShapeLayer()shapeMask.path=outerPath.cgPathself.insertSublayer(gradient,at:0) 最佳答案 让CAShap