layui菊花_一个加载菊花的小demo

#import "SSProgress.h"

@implementation SSProgress

+ (instancetype)shareInstence {

static SSProgress * instance = nil;

static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{

instance = [[SSProgress alloc]init];

});

return instance;

}

- (void)showloading

{

UIWindow *window = [UIApplication sharedApplication].delegate.window;

[window addSubview:self.bgV];

[self.bgV addSubview:self.blackView];

}

- (void)hidLoading

{

[self.bgV removeFromSuperview];

}

- (UIView *)bgV

{

if (!_bgV) {

_bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];

_bgV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.01];

}

return _bgV;

}

- (UIView *)blackView

{

if (!_blackView) {

_blackView = [[UIView alloc] initWithFrame:CGRectMake((WIDTH-kPERCENT(64))*.5, HEIGHT*.5-kPERCENT(64), kPERCENT(64), kPERCENT(64))];

_blackView.layer.cornerRadius = kPERCENT(2);

_blackView.backgroundColor = [BLACK_COLOR colorWithAlphaComponent:0.6];

CGFloat kSpaceBetweenRect = 3.0;

NSInteger kRectCount = 5;

UIView *loadingView = [[UIView alloc] initWithFrame:CGRectMake(kPERCENT(12), kPERCENT(12), kPERCENT(40), kPERCENT(40))];

[_blackView addSubview:loadingView];

CGFloat rectWidth = (loadingView.frame.size.width - kSpaceBetweenRect *(kRectCount-1)) / kRectCount;

for (NSInteger i = 0; i < kRectCount; ++i) {

CALayer *layer = [CALayer layer];

layer.transform = CATransform3DMakeScale(1.0, 0.4, 0.0);

layer.backgroundColor = [UIColor lightGrayColor].CGColor;

layer.frame = CGRectMake(i * (rectWidth + kSpaceBetweenRect), 0, rectWidth, loadingView.frame.size.height);

[loadingView.layer addSublayer:layer];

}

for (NSInteger i = 0; i < kRectCount; ++i) {

CALayer *layer = loadingView.layer.sublayers[i];

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

animation.removedOnCompletion = NO;

animation.repeatCount = INTMAX_MAX;

animation.duration = .8f;

animation.beginTime = CACurrentMediaTime() + i * 0.1;

animation.keyTimes = @[@0.0,@0.2, @0.4,@1.0];

animation.timingFunctions = @[

[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],

[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],

[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],

[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]

];

animation.values = @[

[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 0.4, 0.0)],

[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 0.0)],

[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 0.4, 0.0)],

[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 0.4, 0.0)]

];

[layer addAnimation:animation forKey:[NSString stringWithFormat:@"wave_animation_%lu",i]];

}

}

return _blackView;

}

@end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值