代码库> 指示器> 联网指示器
联网指示器
关注
上传者:wen2011 分类:指示器(Activity Indicator)
查看次数:2930 下载次数:295
上传时间:2015-03-17 大小:71 B
- (id)initWithFrame:(CGRect)frame andStyle:(WMProgressStyle)styleType andTitle:(NSString *)title
{
    if (self = [super initWithFrame:frame]) {
        _frame = frame;
        self.styleType = styleType;
        self.titleStr = title;
        [self createProgress];
    }
    return self;
}

- (void)createProgress
{
    //create backgroundView
    self.progressView = [[UIView alloc]initWithFrame:_frame];
    self.progressView.alpha = 0.5;
    self.progressView.backgroundColor = [UIColor blackColor];
    
    [self addSubview:_progressView];
    
    //activityView
    self.activityView = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(_frame.size.width/2, _frame.size.height/2-10, 0, 0)];
    [self.progressView addSubview:self.activityView];
    
    if (self.styleType == defaultStyle) {
        self.activityView.activityIndicatorViewStyle = 0;
    }
    
    if (self.styleType == titleStyle) {
        UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, _frame.size.height/2+5, _frame.size.width, 30)];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.font = [UIFont systemFontOfSize:12];
        titleLabel.text = self.titleStr;
        [self.progressView addSubview:titleLabel];
    }
    
}

- (void)startWMProgress
{
    [self.activityView startAnimating];
}

- (void)stopWMProgress
{
    [self.activityView stopAnimating];
    for (UIView *view in self.subviews) {
        [view removeFromSuperview];
    }
}
收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0


综合评论
提示
sina weixin mail 回到顶部