我的UIView子类layoutSubviews()函数包含以下内容:
var path = UIBezierPath()
path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: [UIRectCorner.allCorners], cornerRadii: CGSize(width: 10.0, height: 10.0))
self.fillLayer.path = path.cgPath
self.maskLayer.path = path.cgPath
我在我的UIView图层上做了一个简单的缩放动画:保持它的位置并将其高度延长2倍。
所有这些都适用于这些CABasicAnimations:
let scale:CABasicAnimation = CABasicAnimation.init(keyPath:"transform.scale.y");
scale.fromValue = 1.0;
scale.toValue = 2.0;
scale.duration = 10.0;
scale.isRemovedOnCompletion = false;
scale.fillMode = kCAFillModeForwards;
let position:CABasicAnimation = CABasicAnimation.init(keyPath:"position.y");
position.byValue = layer.frame.height/2;
position.duration = 10.0;
position.isRemovedOnCompletion = false;
position.fillMode = kCAFillModeForwards;
let cornerRadius:CABasicAnimation = CABasicAnimation.init(keyPath:"cornerRadius");
cornerRadius.byValue = 0;
cornerRadius.duration = 10.0;
cornerRadius.isRemovedOnCompletion = false;
cornerRadius.fillMode = kCAFillModeForwards;
layer.cornerRadius = 10.0;
layer.add(position, forKey: "basic1");
layer.add(scale, forKey: "basic2");
layer.add(cornerRadius, forKey: "cornerRadius");
但问题是在动画完成后我的圆角看起来伸展开来,我不知道如何防止这种情况发生,除非我创建3个视图,顶部,底部和中间,并且仅拉伸中间。
这是图片中的问题 - 请查看我想要的动画后角落的左侧绿色uiview,以及我目前正在获取的后动画角落的右侧绿色uiview
感谢!!!