IOS自定义一个进度条

Home / Article MrLee 2014-11-17 2543

IOS6之后就不支持改写alertview,那么我们有这个需要怎么办?
答案很简单,自己定义呗……(自己动手,丰衣足食)
//
//  UIProcessDialog.m
//  XQQ
//
//  Created by leehom on 14-11-17.
//  Copyright (c) 2014年 leehom. All rights reserved.
//
#import "UIProcessDialog.h"
@implementation UIProcessDialog
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self setBackgroundColor:[UIColor clearColor]];
        self.aView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        self.aView.center = CGPointMake(self.center.x,self.center.y);
        [self.aView startAnimating];
        [self addSubview:self.aView];
    }
    return self;
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
    // What rectangle am I filling?
    NSString *text = @"处理中,请稍后...";
    UIFont *font = [UIFont boldSystemFontOfSize:15];
    CGRect textRect;
    textRect.size = [text sizeWithFont:font];
    textRect.origin.x = self.center.x - textRect.size.width / 2.0;
    textRect.origin.y = self.bounds.size.height - textRect.size.height * 2.0;
    // Set the fill color of the current context to black
    [[UIColor whiteColor] setFill];
    CGSize offset = CGSizeMake(4, 3);
    CGColorRef color = [[UIColor darkGrayColor] CGColor];
    CGContextSetShadowWithColor(UIGraphicsGetCurrentContext(), offset, 2.0, color);
    // Draw the string
    [text drawInRect:textRect withFont:font];
}

@end

本文链接:https://www.it72.com/237.htm

推荐阅读
最新回复 (0)
返回