我有四個UIbuttons,我必須改變自己的x原點。現在我用這個方法:如何創建一個動畫塊IOS
[UIView animateWithDuration:1.0
delay:1.0
options: UIViewAnimationCurveEaseInOut
animations:^{
self.Button1.frame = CGRectMake(-120, self.Button1.frame.origin.y, self.Button1.frame.size.width, self.Button1.frame.size.height);
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0
delay:1.0
options: UIViewAnimationCurveEaseInOut
animations:^{
self.Button1.frame = CGRectMake(-140, self.Button1.frame.origin.y, self.Button1.frame.size.width, self.Button2.frame.size.height);
}
completion:^(BOOL finished){
}];
}];
我把一個動畫在接下來的completition部分。但我有4/5按鈕。我不能這麼做很多次。有沒有辦法做一個物體上的動畫,經過0.5秒的延遲做它的下一個?
編輯:
我試圖用這樣的:
typedef void (^AnimationBlock)();
AnimationBlock firstAnimation = ^{ self.Button1.frame = CGRectMake(-120, self.Button1.frame.origin.y, self.Button1.frame.size.width, self.Button1.frame.size.height); };
AnimationBlock secondAnimation = ^{ self.Button4.frame = CGRectMake(-120, self.Button4.frame.origin.y, self.Button4.frame.size.width, self.Button4.frame.size.height);};
[UIView animateWithDuration:2 animations:firstAnimation completion:^(BOOL finished) {
[UIView animateWithDuration:2 animations:secondAnimation];
}];
,但有沒有可能設置兩個動畫之間的時間。