相关疑难解决方法(0)

如何在分层视图的顶部在Objective C中显示动画GIF?

我想在mac OSX应用程序中在我的屏幕上绘制动画gif.我使用这段代码插入gif:我可以看到Gif为1张图片它不会动画只有静态图片:(我应该添加什么才能使其动画?

#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>//for drawing circle
#import "sharedPrefferences.h"
@interface GenericFanSubView : NSView
{
    NSColor * _backgroundColor;
    NSImageView* imageView;
}

- (void)setBackgroundColor :(NSColor*)color;

- (void)insertGif1;
- (void)insertGif2;
- (void)insertGif3;
@end

#import "GenericFanSubView.h"
#define PI 3.14285714285714

@implementation GenericFanSubView

- (id)initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    // Initialization code here.
            imageView = [[NSImageView alloc]initWithFrame:CGRectMake(0, 0,self.frame.size.width,self.frame.size.height)];

        [imageView setAnimates: YES];
    }
    return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
    [super drawRect:dirtyRect];
    // Drawing code here.
    [self drawCircleInRect];
    _backgroundColor = [NSColor whiteColor];
    [self …
Run Code Online (Sandbox Code Playgroud)

macos cocoa objective-c animated-gif nsimage

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

animated-gif ×1

cocoa ×1

macos ×1

nsimage ×1

objective-c ×1