美文网首页
菊花转的封装

菊花转的封装

作者: 天涯海角我爱你 | 来源:发表于2016-06-14 20:22 被阅读50次

一 声明方法

#import@interface MyLodingView : UIView

+ (void)showLoadingWithAfterDelay:(NSTimeInterval)second superView:(UIView *)superView;

@end

二  实现方法

#import "MyLodingView.h"

#define KScreenWidth [[UIScreen mainScreen]bounds].size.width

#define KScreenHeight [[UIScreen mainScreen]bounds].size.height

#define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]

@implementation MyLodingView

+ (void)showLoadingWithAfterDelay:(NSTimeInterval)second superView:(UIView *)superView

{

MyLodingView *myLodingView = [[MyLodingView alloc] initWithFrame:CGRectMake(KScreenWidth / 2 - 50 , KScreenHeight / 2 - 50, 100, 100)];

UIActivityIndicatorView *juhua = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0 , 0, 100, 100)];

juhua.backgroundColor = COLOR(81, 191, 156, 1);

juhua.layer.cornerRadius = 10;

juhua.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;

[juhua startAnimating];

UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(10, 70, 80,40)];

label.text = @"loading...";

label.font = [UIFont systemFontOfSize:13];

label.textColor = [UIColor whiteColor];

[juhua addSubview:label];

[myLodingView addSubview:juhua];

[superView addSubview:myLodingView];

[myLodingView performSelector:@selector(hideLoading:) withObject:juhua afterDelay:second];

}

// 自动消失菊花

- (void)hideLoading:(UIActivityIndicatorView *)juhua

{

[juhua stopAnimating];

[juhua removeFromSuperview];

}

相关文章

网友评论

      本文标题:菊花转的封装

      本文链接:https://www.haomeiwen.com/subject/ocmudttx.html