我有一个包含几个子视图的屏幕。在用户的交互上,我想再添加一个子视图,改变其他子视图的位置,让它们同时消失。我的代码是:
[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 到另一个,所以它的视图也被添加为子视图。这可能是问题吗?