2010-09-08 15 views

cevap

12

UIView'da -beginAnimations:context: ve -commitAnimations yöntemlerini arıyorsunuz. Özetle

, sen böyle bir şey yapmak: iOS4 için

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

Mükemmel! Çok teşekkür ederim :) – Nippysaurus

13

ve bu documentation caydırılmıştır olarak daha sonra, beginAnimations:context ve commitAnimations kullanmamalısınız.

Bunun yerine blok temelli yöntemlerden birini kullanmalıdır.

Yukarıdaki örnek daha sonra şu şekilde görünecektir:

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

bir UILabel ile bir örnektir - animasyon 0.3 saniyede soldan etiketin kayar.

// 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; 
}]; 
İlgili konular