यह पुराना क्यू हो सकता है लेकिन यह विषय के खोज परिणामों के शीर्ष के पास है। यहाँ एक और अधिक कटौती और सूखी समाधान है: रोक निकालने के लिए,
CABasicAnimation *rotation;
rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotation.fromValue = [NSNumber numberWithFloat:0];
rotation.toValue = [NSNumber numberWithFloat:(2*M_PI)];
rotation.duration = 1.1; // Speed
rotation.repeatCount = HUGE_VALF; // Repeat forever. Can be a finite number.
[yourView.layer addAnimation:rotation forKey:@"Spin"];
तब (QuartzCore आयात करने के लिए सुनिश्चित कर लें/QuartzCore.h)/रीसेट एनिमेशन: (कैसे रोक-इन-जगह पर के लिए टिप्पणियों देखें)
[yourView.layer removeAnimationForKey:@"Spin"];
तेज में:
let rotation = CABasicAnimation(keyPath: "transform.rotation")
rotation.fromValue = 0
rotation.toValue = 2 * M_PI
rotation.duration = 1.1
rotation.repeatCount = Float.infinity
view.layer.addAnimation(rotation, forKey: "Spin")
स्रोत
2012-08-24 16:08:56
आप 'UIImageView' अंदर गेंद को घुमाने की जरूरत है? यदि हां 'UIImageView' के एनीमेशन विधियों का उपयोग करने पर विचार करें – Saphrosit