I try to move an ImageView (say, view1) so that its center matches another ImageView's center (view2), while resizing it. On completion this first view is removed, but is image is copied into the view2, so its image seems to remain. For that purpose I tried many combinations but with any, even creating a new ImageView3 that I can insert into view2, as soon as I try to set the center of view3 to match the center of view2, nothing happens and my image disappears, never being inserted in view2. Without setting the center, everything works. Damn, Why? Did I miss something obvious or am I stupid? Or should I definitely use coreAnimation?
[UIView animateWithDuration:0.5 animations:^{
view1.center = view2.center;
view3.center = view开发者_如何学Go2.center;
} completion:^(BOOL finished){
[view2 addSubview:view3];
}];
In the completion block, you add view3 as a subview to view2. This is probably not what you want, at least not without further adjusting its position. Since you have reset its center in the animation, the coordinates are based on the parent view. When you add it to view2, the apparent position shifts based on the relative position of view2.
精彩评论