23 Mart 2012, Cuma
Sonsuz 360 derece döndürme animasyon UİView?
UIImageView
360 derece döndürmek için çalışıyorum, ve bazı dersler online olarak görünüyordu. Hiçbiri çalışma, UIView
ya da durdurma, ya da yeni bir pozisyon için Atlama olmadan alabilirim.
- Bunu nasıl başarabilir?
Denedim en son şey
[UIView animateWithDuration:1.0
delay:0.0
options:0
animations:^{
imageToMove.transform = CGAffineTransformMakeRotation(M_PI);
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
Ama eğer 2*pi kullanıyorum eğer aynı pozisyonda beri) hareket etmiyor. Eğer sadece pi (180 derece) yapmaya çalışıyorum işe yarıyor, ama eğer bu yöntemi tekrar ararsam, geri döner.
EDİT:
[UIView animateWithDuration:1.0
delay:0.0
options:0
animations:^{
[UIView setAnimationRepeatCount:HUGE_VALF];
[UIView setAnimationBeginsFromCurrentState:YES];
imageToMove.transform = CGAffineTransformMakeRotation(M_PI);
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
da çalışmıyor. 180 derece gider, bölünmüş bir saniye duraklar, tekrar başlamadan önce 0 dereceye sıfırlar.
CEVAP
23 Mart 2012, Cuma
Benim için mükemmel bir şekilde çalışan bir yöntem (biraz değiştirdim) bulundu: iphone UIImageView rotation
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
Bunu Paylaş:
UİView animasyon vs CALayers iPhone...
UİView bir animasyon iptal?...
iPhone UİView Animasyon En İyi Uygulam...
rotasyon-animasyon y css sonsuz. Nasıl...
Nasıl ünvan değişikliği istenmeyen UİB...