#import "ViewController.h"
#import <Quartz/Quartz.h>
@interface ViewController()
{
NSArray *activityAnimationImages;
IBOutlet NSImageView *activityImageView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSMutableArray *array = [NSMutableArray array];
for (NSUInteger i = 0; i<=29; i++)
{
//Preloader is a set of images
NSImage *image = [NSImage imageNamed:[NSString stringWithFormat:@"Preloader_10_000%02lu",(unsigned long)i]];
[array addObject:image];
}
activityAnimationImages = [NSArray arrayWithArray:array];
//Create layer
CALayer *layer = [CALayer layer];
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
[animation setCalculationMode:kCAAnimationDiscrete];
[animation setDuration:1.0f];
[animation setRepeatCount:HUGE_VALF];
[animation setValues:activityAnimationImages];
[layer setFrame:NSMakeRect(0, 0, 100, 100)];
layer.bounds = NSMakeRect(0, 0, 100, 100);
[layer addAnimation:animation forKey:@"contents"];
[activityImageView setLayer:[CALayer layer]];
[activityImageView setWantsLayer:YES];
[activityImageView.layer addSublayer:layer];
}
ありがとうございます。これを試してみましょう。 –
@ X.Rodiそれがうまくいけば、答えを受け入れてください:) – Jeyamahesan