「画像」アニメーションをの
multiple images
に与える方法を 'UIView'で教えてください。UIViewの異なる場所にある複数の画像にアニメーションを与える方法は?
1)私は3つの画像を持っていました。
2)私は生き生き3 different locations
でこれら3 Images
を追加したいが、1枚の画像some duration
とanimatedly
ずつを追加意味します?
どうすればこの問題を解決できますか?
「画像」アニメーションをの
multiple images
に与える方法を 'UIView'で教えてください。UIViewの異なる場所にある複数の画像にアニメーションを与える方法は?
1)私は3つの画像を持っていました。
2)私は生き生き3 different locations
でこれら3 Images
を追加したいが、1枚の画像some duration
とanimatedly
ずつを追加意味します?
どうすればこの問題を解決できますか?
あなたは、第2の画像をアニメーション化するというように、コード
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"-t%d",1]]];
[imgView setBackgroundColor:[UIColor redColor]];
UIImageView *imgView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"-t%d",2]]];
[imgView2 setBackgroundColor:[UIColor redColor]];
UIImageView *imgView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"-t%d",2]]];
[imgView3 setBackgroundColor:[UIColor redColor]];
[self.view addSubview:imgView];
[self.view addSubview:imgView2];
[self.view addSubview:imgView3];
[UIView animateWithDuration:0.5 delay:1.0 options:UIViewAnimationOptionLayoutSubviews animations:^{
[imgView setFrame:CGRectMake(0, 0, 150, 150)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.5 delay:1.0 options:UIViewAnimationOptionLayoutSubviews animations:^{
[imgView2 setFrame:CGRectMake(self.view.frame.size.width - 150, 0, 150, 150)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.5 delay:1.0 options:UIViewAnimationOptionLayoutSubviews animations:^{
[imgView3 setFrame:CGRectMake(0, self.view.frame.size.height - 150, 150, 150)];
} completion:^(BOOL finished) {
}];
}];
}];
以下のようにそれに役立つだろう最初のイメージアニメーションの目的での使用済みブロックのための画像1
一つをアニメーションにしたいあなたの要件ごとにあなた:
@PKT ....あなたのコードはうまくいきます –
3つのビュー_redView
、_greenView
と言うと_blueView
別の場所に一方からそれらを移動させる方法以下のチェックアウトします。私はあなたが望むならば、あなたが特定することができるランダムな場所を使用しました。 Here you can have working example of itちょうどViewAnimationsTest
作業空間のプロジェクトを選択して実行してください。
- (int) randomFloatingGenerator : (int) max{
return arc4random() % max;
}
- (void) animate3Views {
[UIView animateWithDuration:2.0
animations:^{
_redView.transform = CGAffineTransformMakeTranslation([self randomFloatingGenerator : 270], [self randomFloatingGenerator:480]);
_greenView.transform = CGAffineTransformMakeTranslation([self randomFloatingGenerator : 270], [self randomFloatingGenerator:480]);
_blueView.transform = CGAffineTransformMakeTranslation([self randomFloatingGenerator : 270], [self randomFloatingGenerator:480]);
} completion:^(BOOL finished) {
[self animate3Views];//if don;t want continuous translation remove this line
}];
}
ここでは、その実例を持つことができます、https://github.com/rptwsthi/DevelopmentSupportWorkspaceちょうどViewAnimationsTestプロジェクトを選択作業スペースと実行します。 – rptwsthi
@rptwsthi ...その例では、使用する必要のあるものを教えてください。 –
おそらく最も簡単な方法は、遅延付きのアニメーションを3つ使用することです。 myViewsをアニメーション化するビューの配列である
for (NSInteger i = 0; i < 3; i++) {
UIView *view = myViews[i];
CGRect frame = [self frameForViewAtIndex: i];
NSTimeInterval duration = 0.5;
NSTimeInterval delay = i * 0.5;
[UIView animateWithDuration: duration delay: delay options: 0 animations: ^{
view.frame = frame;
} completion: nil];
}
は、frameForViewAtIndex:ビューに対応するフレームを返すメソッドです。
@roselovelyこのコードでは何かが明確ではありませんか? –
....画像を追加する方法を教えてください。 –
あなたは腹腔領域のために遅くするためにuiimageviewアニメーションを速く必要としますか? – Shreyank
UIView animateWithDuration? –
@Shreyank ....遅くなるのは遅くない...しかし、3つの異なる場所で1つずつ、3つの画像を1つずつ追加したい... 1つの画像を1つの場所に配置した後、その画像を配置した後、次の画像をアニメーションしてそのような次の場所に –