3

Say I have two view controllers, A and B. UIView instance viewObject is subview of A in the nib, with frame 0, 0, 100, 100.

Now I execute the following

[UIView animateWithDuration:0.5 animations:^{[viewObject setFrame:CGFrameMake(100, 100, 100, 100)];}];

It worked all fine. But when I call:

[self presentViewController:B animated:YES completion:NULL];

viewObject appears to jump back to the frame before the animateWithDuration:animations: message during the transition of the view controllers.

Likewise when I dismiss B the viewObject is at its position in the nib.

How do I make viewObject stay in the same place?

4

1 回答 1

-1

尝试设置

[viewObject setClipsToBounds:YES]

至少在第二个动画之前。如果您需要它不要剪辑到边界(因为阴影等),您可以在第二个动画完成后将属性重置为 no。

每次我遇到这个问题时,它都对我有用。

于 2013-06-06T07:02:57.780 回答