#import <UIKit/UIKit.h>
@interface LoadAnimAtion : UIView
-(instancetype)initWithFrame:(CGRect)frame;
-(void)loadAnimAtion;
@end
/
#import "LoadAnimAtion.h"
@implementation LoadAnimAtion
-(instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor whiteColor];
[self loadAnimAtion];
}
return self;
}
-(void)loadAnimAtion
{
CAReplicatorLayer * replicatorLayer = [CAReplicatorLayer layer];
replicatorLayer.frame = CGRectMake(Screen_width/2-75, Screen_height/2-75-64, 150, 150);
replicatorLayer.cornerRadius = 10.0;
[self.layer addSublayer:replicatorLayer];
CALayer * dotLayer = [CALayer layer];
dotLayer.bounds = CGRectMake(0, 0, 20, 20);
dotLayer.position = CGPointMake(50, 20);
dotLayer.backgroundColor = purColor.CGColor;
dotLayer.cornerRadius = 10;
dotLayer.masksToBounds = YES;
[replicatorLayer addSublayer: dotLayer];
CGFloat count = 10.0;
replicatorLayer.instanceCount = count;
CGFloat angel = 2* M_PI/count;
replicatorLayer.instanceTransform = CATransform3DMakeRotation(angel, 0, 0, 1);
CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.duration = 1.0;
animation.fromValue = @1;
animation.toValue = @0.1;
animation.repeatCount = MAXFLOAT;
[dotLayer addAnimation:animation forKey:nil];
replicatorLayer.instanceDelay = 1.0/ count;
dotLayer.transform = CATransform3DMakeScale(0.01, 0.01, 0.01);
}
@end
网友评论