iOS - animate movement of a label or image

后端 未结 3 1558
南笙
南笙 2020-12-31 08:46

How can I animate the movement of a label or image? I would just like to make a slow transition from one location on the screen to another (nothing fancy).

3条回答
  •  醉酒成梦
    2020-12-31 09:10

    For ios4 and later you should not use beginAnimations:context and commitAnimations, as these are discouraged in the documentation.

    Instead you should use one of the block-based methods.

    The above example would then look like this:

    [UIView animateWithDuration:0.3 animations:^{  // animate the following:
        myLabel.frame = newRect; // move to new location
    }]; 
    

提交回复
热议问题