2010-09-08 11 views

risposta

12

Stai cercando i metodi -beginAnimations:context: e -commitAnimations su UIView.

In poche parole, si fa qualcosa di simile:

[UIView beginAnimations:nil context:NULL]; // animate the following: 
myLabel.frame = newRect; // move to new location 
[UIView setAnimationDuration:0.3]; 
[UIView commitAnimations]; 
+0

Perfetto! Grazie mille :) – Nippysaurus

13

Per iOS4 e poi non si dovrebbe usare beginAnimations:context e commitAnimations, in quanto questi sono scoraggiati nella documentation.

Invece si dovrebbe usare uno dei metodi basati su blocchi.

L'esempio di cui sopra sarebbe quindi simile a questa:

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

Ecco un esempio con un UILabel - l'animazione scorre l'etichetta dalla in 0,3 secondi a sinistra.

// Save the original configuration. 
CGRect initialFrame = label.frame; 

// Displace the label so it's hidden outside of the screen before animation starts. 
CGRect displacedFrame = initialFrame; 
displacedFrame.origin.x = -100; 
label.frame = displacedFrame; 

// Restore label's initial position during animation. 
[UIView animateWithDuration:0.3 animations:^{ 
    label.frame = initialFrame; 
}]; 
Problemi correlati