UIView
我通过添加图层蒙版为我的子类添加了圆角。以下是 Montouch 代码,但在 ObjC 中也应该很容易理解其含义:
// Add a layer that holds the rounded corners.
UIBezierPath oMaskPath = UIBezierPath.FromRoundedRect (this.Bounds, this.eRoundedCorners, new SizeF (this.fCornerRadius, this.fCornerRadius));
private void UpdateMask()
{
if(this.Layer.Mask == null)
{
CAShapeLayer oMaskLayer = new CAShapeLayer ();
oMaskLayer.Frame = this.Bounds;
// Set the newly created shape layer as the mask for the image view's layer
this.Layer.Mask = oMaskLayer;
}
((CAShapeLayer)this.Layer.Mask).Path = oMaskPath.CGPath;
}
我已经超载了Frame
财产。设置框架会调整蒙版以保持圆角的形状。
但是,如果我对帧大小的变化进行动画处理,则掩码会立即设置为动画的目标值。
有没有办法让我的视图检测到它是动画的一部分并使蒙版正确动画?