0
我有一個從UIView繼承的自定義類。在繪製方法中,我畫了幾個形狀,包括一些圓圈。我想爲彼此獨立的圓圈的顏色(現在的筆劃顏色)設置動畫,例如,我希望一個或多個圓圈的顏色「脈衝」或閃光(使用緩入/緩出而不是線性)。在UIView中動畫多個形狀
什麼是最好的方法來存檔這個?
能夠使用內置的動畫代碼(CABasicAnimation等)會很棒,但我不知道該怎麼做?
編輯:這是涉及的代碼。 (我使用Xamarin.iOS,但我的問題不是特定於此)。
CGColor[] circleColors;
public override void Draw (RectangleF rect)
{
base.Draw (rect);
using (CGContext g = UIGraphics.GetCurrentContext()) {
g.SetLineWidth(4);
float size = rect.Width > rect.Height ? rect.Height : rect.Width;
float xCenter = ((rect.Width - size)/2) + (size/2);
float yCenter = ((rect.Height - size)/2) + (size/2);
float d = size/(rws.NumCircles*2+2);
var circleRect = new RectangleF (xCenter, yCenter, 0, 0);
for (int i = 0; i < rws.NumCircles; i++) {
circleRect.X -= d;
circleRect.Y -= d;
circleRect.Width += d*2;
circleRect.Height += d*2;
CGPath path = new CGPath();
path.AddEllipseInRect (circleRect);
g.SetStrokeColor (circleColors [i]);
g.AddPath (path);
g.StrokePath();
}
}
}
發佈您的代碼,我們將能夠更好地爲您提供幫助。 – 2014-11-24 17:24:53