グラフをアニメーション化したいという問題が1つあります。そのために、各グラフの透明な静的画像があります。これは、水平グラフであり、左から右のグラフを意味します。
最初に幅= 0を維持し、アニメーションを使用して幅を画像の元の幅に拡大できるように、この画像を拡大したくありません。これは望ましくありません。
カルディオグラフのようにグラフが描かれているように見える画像が欲しいです。Cardiograph の静止画像があり、アニメーションしていることを示したいと思います。
これを行う方法?
グラフをアニメーション化したいという問題が1つあります。そのために、各グラフの透明な静的画像があります。これは、水平グラフであり、左から右のグラフを意味します。
最初に幅= 0を維持し、アニメーションを使用して幅を画像の元の幅に拡大できるように、この画像を拡大したくありません。これは望ましくありません。
カルディオグラフのようにグラフが描かれているように見える画像が欲しいです。Cardiograph の静止画像があり、アニメーションしていることを示したいと思います。
これを行う方法?
画像を循環バッファーとして使用できます。つまり、アンカー x 座標を移動するだけです。
Create your image over say a white background. The whole graph image. Crate another completely white view and overlay that over the graph image. Then you can animate the top image so the left side slowly moves to the right - so x increases as width decreases.
EDIT: For example, if you have three views, and you want to animate something over all three, you can use something like the code below, which slowly shows a solid color overlay over each view, then apparently slides out of view to the left (like a curtain):
UIView *coverView1 = [UIView alloc] initWithFrame:(CGRect){ {0,0}, graph1View.frame.size}];
coverView1.backgroundColor = [UIColor redColor];
coverView1.alpha = 0;
[graphView1 addSubview:coverView1];
UIView *coverView2 = [UIView alloc] initWithFrame:(CGRect){ {0,0}, graph2View.frame.size}];
coverView2.backgroundColor = [UIColor greenColor];
coverView2.alpha = 0;
[graphView2 addSubview:coverView2];
UIView *coverView3 = [UIView alloc] initWithFrame:(CGRect){ {0,0}, graph3View.frame.size}];
coverView3.backgroundColor = [UIColor blueColor];
coverView3.alpha = 0;
[graphView3 addSubview:coverView3];
[UIView animateWithDuration:0.5 animations:^
{
coverView1.alpha = 1;
coverView2.alpha = 1;
coverView3.alpha = 1;
}
completion:^(BOOL finished)
{
[UIView animateWithDuration:0.5 animations:^
{
CGRect frame;
frame = coverView1.frame, frame.size.width = 0, coverView1.frame = frame;
frame = coverView2.frame, frame.size.width = 0, coverView2.frame = frame;
frame = coverView3.frame, frame.size.width = 0, coverView3.frame = frame;
}
completion:^(BOOL finished)
{
[coverView1 removeFromSuperview];
[coverView2 removeFromSuperview];
[coverView3 removeFromSuperview];
} ];
} ];
This code typed in here so may have small typos etc.