Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 如何轻松设置NSImage的动画?_Xcode_Animation_Notifications_Nsview - Fatal编程技术网

Xcode 如何轻松设置NSImage的动画?

Xcode 如何轻松设置NSImage的动画?,xcode,animation,notifications,nsview,Xcode,Animation,Notifications,Nsview,我在NSImage中创建了一个NSView,我希望通过NSNotificationCenter发送开始和停止通知来设置该NSView的动画 我要走哪条路才能实现这一点 我的密码是: @implementation SyncToolbarItemView - (id)init { self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)]; if (self) { // Initial

我在NSImage中创建了一个NSView,我希望通过NSNotificationCenter发送开始和停止通知来设置该NSView的动画

我要走哪条路才能实现这一点

我的密码是:

@implementation SyncToolbarItemView

- (id)init
{
    self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
    if (self)
    {
        // Initialization code here.
    
        // Add observers
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startSyncing) name:NOTIFICATION_START_CHECK_TAG_PROCESS object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopSyncing) name:NOTIFICATION_FINISHED_CHECK_TAG_PROCESS object:nil];
    }

    return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
    // Init image
    img_sync = [[NSImageView alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 32.0f, 32.0f)];
    [img_sync setImage:[NSImage imageNamed:@"icon_sync.png"]];

    // Add to view
    [self addSubview:img_sync];

    [img_sync release];
}

- (void) startSyncing
{

}

- (void) stopSyncing
{

}

@end

您应该看看CoreAnimation参考,它非常清楚地说明了如何为NSImageView等控件设置动画