美文网首页
Mac开发 - NSImageView加载Gif图片

Mac开发 - NSImageView加载Gif图片

作者: H了个L | 来源:发表于2017-10-19 22:39 被阅读50次
  • 将资源文件拖入项目
  • 设置NSImageView的animates为YES
  • 使用代码设置image
- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.loginAnimateView.image = [[NSImage alloc] initWithData:
                                   [NSData dataWithContentsOfFile:
                                    [[NSBundle mainBundle] pathForResource:@"xs_login_animate" ofType:@"gif"]]];
}

对于pathForResource:加载出来的资源路径为nil可以参考这篇文章: Mac开发 - NSBundle 加载资源文件

相关文章

网友评论

      本文标题:Mac开发 - NSImageView加载Gif图片

      本文链接:https://www.haomeiwen.com/subject/kjapuxtx.html