首页 > 其他 > 详细

MBProgressHud添加自定义动画

时间:2016-09-26 12:32:05      阅读:335      评论:0      收藏:0      [点我收藏+]

在使用自定义view时,若直接使用,如下

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.label.text = @"加载中…";
hud.mode = MBProgressHUDModeCustomView;
UIImage *image = [[UIImage imageNamed:@"toast_loading"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
hud.customView = imgView;

hud.bezelView.color = [UIColor colorWithWhite:0.0 alpha:1];
//文字颜色
hud.contentColor = [UIColor whiteColor];
hud.animationType = MBProgressHUDAnimationFade;

那么效果为

技术分享

若想使自定义view有动态效果,那么需要对UIImageView添加动画

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.label.text = @"加载中…";
hud.mode = MBProgressHUDModeCustomView;
UIImage *image = [[UIImage imageNamed:@"toast_loading"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
anima.toValue = @(M_PI*2);
anima.duration = 1.0f;
anima.repeatCount = 10;
[imgView.layer addAnimation:anima forKey:nil];
hud.customView = imgView;

hud.bezelView.color = [UIColor colorWithWhite:0.0 alpha:1];
//文字颜色
hud.contentColor = [UIColor whiteColor];
hud.animationType = MBProgressHUDAnimationFade;

此时效果为

技术分享

最后补充,若想设置hud大小,可以用

hud.minSize = CGSizeMake(165,90);

 

MBProgressHud添加自定义动画

原文:http://www.cnblogs.com/Apologize/p/5908555.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!