首页 > 其他 > 详细

自定义选择动画提示

时间:2014-09-13 22:40:06      阅读:308      评论:0      收藏:0      [点我收藏+]
#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]; }

 

自定义选择动画提示

原文:http://www.cnblogs.com/hw140430/p/3970380.html

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