你可以簡單的動畫的NSTextField的位置和動畫師像
[[textField animator] setFrameOrigin:NSMakePoint(x,y)];
你也可以將它嵌入到這樣的「CATrancation」代碼:
[CATransaction begin];
[CATransaction setAnimationDuration:0.5];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[[textField animator] setFrameOrigin:NSMakePoint(x,y)];
[CATransaction commit];
如果你需要動畫的委託,就可以使用CABasicAnimation
CABasicAnimation* animation = [CABasicAnimation animation];
animation.delegate = self;
NSDictionary *animations = [NSDictionary dictionaryWithObjectsAndKeys:animation,@"frameOrigin",nil];
[textField setAnimations:animations];
[[textField animator] setFrameOrigin:NSMakePoint(x,y)];
代表方法是
- (void)animationDidStart:(CAAnimation *)theAnimation;
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag;
如果您需要掩蓋您的文本字段,只需將其嵌入到其他NSView中即可。
你試試這個... http://stackoverflow.com/questions/7266766/making-uitextview-scroll-programmatically –
它與一個計時器,而這正是我想避免做什麼。 – NSAddict
我不擅長動畫中的可可。 NSAnimation會做butttttt ...它再次使用計時器調用隱式。 –