#import <Cocoa/Cocoa.h>
@interface GifView : NSView
- (void)setImage:(NSImage*)image;
- (void)setImageURL:(NSString*)url;
@end
#import "GifView.h"
@interface GifView()
@property (nonatomic) NSImage *image;
@property (nonatomic) NSBitmapImageRep *gifbitmapRep;
@property (assign) NSInteger currentFrameIdx;
@property (nonatomic) NSTimer *giftimer;
@end
@implementation GifView
- (void)setImage:(NSImage*)img {
if (img) {
_image = img;
self.gifbitmapRep = nil;
if (self.giftimer) {
[self.giftimer invalidate];
self.giftimer = nil;
}
// get the image representations, and iterate through them
NSArray * reps = [self.image representations];
for (NSImageRep * rep in reps) {
// find the bitmap representation
if ([rep isKindOfClass:[NSBitmapImageRep class]] == YES) {
// get the bitmap representation
NSBitma
Mac OS NSView 加载gif图
最新推荐文章于 2022-04-29 12:22:42 发布