首页 > 代码库 > 自定义选择动画提示

自定义选择动画提示

#pragma mark - 创建旋转动画提示- (CustomView *)initIndicatorViewWithTitle:(NSString *)title{    self = [super initWithFrame:[[UIScreen mainScreen] bounds]];    if (self) {                //创建背景视图        UIView *bgView = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];        bgView.alpha = 0.1;//显示此视图时,不可进行其他操作        bgView.backgroundColor = [UIColor grayColor];        [self addSubview:bgView];                //创建活动指示器        UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];                CGFloat x = kScreenW / 2 - 50;        CGFloat y = kScreenH / 2 - 20;        CGFloat w = 100;        CGFloat h = 40;        indicatorView.alpha = 0.5;        indicatorView.frame = CGRectMake(x, y, w, h);                //设置活动指示器的圆角        indicatorView.layer.cornerRadius = 4;        indicatorView.layer.masksToBounds = YES;                //设置活动指示器在自身视图中的位置        indicatorView.bounds = CGRectMake(25, kZero, 90, h);        indicatorView.backgroundColor = [UIColor blackColor];        [indicatorView startAnimating];        [self addSubview:indicatorView];                //创建显示的文本        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(155, y, w, h)];        label.font = [UIFont systemFontOfSize:14];        label.textColor = [UIColor whiteColor];        label.backgroundColor = [UIColor clearColor];        [self addSubview:label];                if ([title isEqualToString:@""] || title == nil) {            label.text = @"加载中";        }else{            label.text = title;        }    }    return self;}
//类方法+ (CustomView *)initIndicatorViewWithTitle:(NSString *)title{ return [[self alloc]initIndicatorViewWithTitle:title];}

 

自定义选择动画提示