我正在創建一個NSView,它的drawRect方法創建並添加一個NSImageView作爲子視圖。旋轉NSView的持有NSImageView
我想旋轉這個NSImageView(circleView)或[self]。因此,在另一種方法,我試圖做到這一點:
-(void)startAnimation {
CABasicAnimation* spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
spinAnimation.toValue = [NSNumber numberWithFloat:5*2*M_PI];
spinAnimation.duration = 2;
[circleView.layer addAnimation:spinAnimation forKey:@"spinAnimation"];
}
但是,此代碼時不被調用的方法做任何事情。難道我做錯了什麼?我試過self.layer和circleView.layer,但似乎都沒有工作...
如果是,可可在OS X? NSView沒有像UIView – mootymoots
addAnimation:選項啓動核心動畫,根據http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/AnimatingLayers.html – mootymoots