• 自定义的进度条


    /** 初始化一个progress,
     aFrame                    外层的大小
     aFrameColor         外层的颜色
     aBarColor               里层的颜色
     gapSize                   里层和外层的间隙
     **/
    
    - (id)initWithFrame:(CGRect)aFrame frameColor:(UIColor *)aFrameColor barColor:(UIColor *)aBarColor aFrameCornerRadius:(CGFloat)aFrameCornerRadius aFrameBorderColor:(CGColorRef)aFrameBorderColor gapSize:(CGFloat)gapSize
    {
        self = [super initWithFrame:aFrame];
        if (self) {
            self.backgroundColor = [UIColor clearColor];
            _gap = gapSize;
            
            _outter = [[UILabel alloc]init];
            _outter.frame = self.bounds;
            _outter.backgroundColor = aFrameColor;
            _outter.layer.borderWidth = 1;
            _outter.layer.borderColor = aFrameBorderColor;
            [self addSubview:_outter];
            
            _inner = [[UILabel alloc]init];
            _inner.frame = CGRectZero;
            _inner.backgroundColor = aBarColor;
            [self addSubview:_inner];
            
            _inner.layer.cornerRadius = aFrameCornerRadius - gapSize;
            _inner.layer.masksToBounds = YES;
            _outter.layer.cornerRadius = aFrameCornerRadius;
            _outter.layer.masksToBounds = YES;
        }
        return self;
    }
    
    
    - (void)setProgress:(float)progress
    {
        progress = progress<0?0:progress;
        progress = progress>1?1:progress;
        _inner.frame = CGRectMake(_gap, _gap, progress*(self.frame.size.width - _gap*2.0), self.frame.size.height - _gap *2.0);
    }
    
    - (void)dealloc
    {
        [_inner removeFromSuperview];
        [_outter removeFromSuperview];
    }
  • 相关阅读:
    一个web应用的诞生(4)
    一个web应用的诞生(7)
    一个web应用的诞生(6)
    HTTP状态码大全(转自wiki)
    十分钟搞懂什么是CGI
    HTTP真的很简单
    QT程序在发布的时候应注意的地方
    QT中获取选中的radioButton的两种方法
    WinEdit编辑器中中文乱码
    C++ lstrlen()
  • 原文地址:https://www.cnblogs.com/cityingma/p/5390535.html
Copyright © 2020-2023  润新知