我的目标是为我的 UI 设置动画,我正在使用 UIView 动画。问题是我一次需要多个动画,但显然我一次只能执行一个 UIView 动画。我之前已经问过这个主题的问题(多个 UIView 动画),所有响应者都说我必须使用类似的方法为动画设置一个委托,animationDidStop:performSelector:
但我想知道是否可以改为将子视图添加到主视图并同时执行动画在每个子视图上。此外,我无法执行背靠背动画,我想也许我可以在 view1 上执行动画,然后在 view2 上执行动画而无需委托。
例如:
//Header
@property (nonatomic, strong) UIView *view1;
@property (nonatomic, retain) UIView *view2;
//Implementation
@synthesize view1;
@synthesize view2;
//ViewDidLoad
view1 = [[UIView alloc]initWithFrame:CGRectMake(0,0,480,640)];
view2 = [[UIView alloc]initWithFrame:CGRectMake(0,0,480,640)];
view1.backgroundColor = [UIColor clearColor];
view2.backgroundColor = [UIColor clearColor];
[performAnimationsOn View1]; //I don't know the code I would put here because the code
//I usually use is [UIView beginAnimation:@"animation"
//context:nil]; but that is a class method and I am not
//sure how to perform an animation on a specific subview.
[performAnimationsOn View2];