0
我已通過添加圖層掩碼向我的子類UIView
添加了圓角。以下是Montouch代碼,但應該是很容易獲得的意義也ObjC:以CAShapeLayer爲掩碼的UIView的子類不能正確動畫
// 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
財產。設置框架會調整蒙版以保持圓角的形狀。
但是,如果我爲框架大小的變化設置了動畫效果,那麼掩碼會立即設置爲動畫的目標值。
有沒有辦法讓我的視圖檢測到它是動畫的一部分,並使屏幕正確動畫?
我看了視頻。我沒有使用明確的動畫。我正在調整UIView的屬性,這會導致圖層屬性的更改,而且不會生成動畫。我試圖爲UIView的圖層設置動畫,但沒有成功:支持UIView的圖層從不動畫。然而,我可以使用隱式動畫來動畫化CAShapeLayer,但同時也會動畫UIView。我迷失在這裏......我怎麼能把兩者結合起來? – Krumelur 2012-02-19 21:09:53