我为nsviewcontroller做动画:
CABasicAnimation *controlPosAnim = [CABasicAnimation animationWithKeyPath:@"position"];
controlPosAnim.delegate = self;
controlPosAnim.duration = 0.5;
NSRect viewRect = [getExternalInfoView.view frame];
NSPoint startingPoint = viewRect.origin;
NSPoint endingPoint = startingPoint;
endingPoint.x += getExternalInfoView.view.frame.size.width + 20;
controlPosAnim.fromValue = [NSValue valueWithPoint:startingPoint];
controlPosAnim.toValue = [NSValue valueWithPoint:endingPoint];
[[getExternalInfoView.view layer] addAnimation:controlPosAnim forKey:@"controlViewPosition"];
getExternalInfoView.view.frame = NSMakeRect(getExternalInfoView.view.frame.origin.x + getExternalInfoView.view.frame.size.width + 20, getExternalInfoView.view.frame.origin.y, getExternalInfoView.view.frame.size.width, getExternalInfoView.view.frame.size.height);
但是我有一点“bug” - 在nstableview的应用程序的未来位置中使黑暗矩形,如“准备未来的视图”(从右向左移动):