我有一个包含多个子视图的屏幕。在用户的交互中,我想添加另一个子视图,更改其他子视图的位置,并使它们同时消失。我的代码是:
[self.view addSubview:imageView];
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
for (UIView *currentItemView in self.currentItemViews) {
currentItemView.center = someCenter;
currentItemView.alpha = 0;
}
} completion:^(BOOL finished) {
}];
在我使用新的子视图添加代码之前一切正常,但现在唯一的动画就是alpha的设置。子视图不会移动。 知道为什么以及如何解决这个问题?
提前致谢!
修改
创建currentItemViews
数组的代码:
self.currentItemViews = [[NSMutableArray alloc] initWithCapacity:6];
for (Item *item in arrayOfItems) {
ItemView *itemView = [[NSBundle mainBundle] loadNibNamed:@"ItemView" owner:self options:nil].lastObject;
itemView.item = item;
[self.currentItemViews addObject:itemView];
[self.view addSubview:itemView];
}
我所在的ViewController
是另一个的childViewController,因此它的视图也被添加为子视图。这可能是问题吗?