zoukankan      html  css  js  c++  java
  • iOS-Quart2D 进度条

    //
    //  HMProgressView.h
    //  进度条
    //
    //  Created by YaguangZhu on 15/9/9.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface HMProgressView : UIView
    
    @property(nonatomic,assign)CGFloat progress;
    
    @end
    
    
    //
    //  HMProgressView.m
    //  进度条
    //
    //  Created by YaguangZhu on 15/9/9.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import "HMProgressView.h"
    @interface HMProgressView()
    
    @property(nonatomic,weak)UILabel *label;
    @end
    
    @implementation HMProgressView
    - (UILabel *)label
    {
        if (_label == nil) {
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
            label.textAlignment = NSTextAlignmentCenter;
            [self addSubview:label];
            _label = label;
        }
        return _label;
    }
    
    - (void)setProgress:(CGFloat)progress
    {
        _progress = progress;
        self.label.text = [NSString stringWithFormat:@"%.2f%%",progress*100];
        [self setNeedsDisplay];
    }
    
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect {
        // Drawing code
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        
        CGPoint center = CGPointMake(50, 50);
        CGFloat startA = -M_PI_2;
        CGFloat radius = 50-2;
        CGFloat endA = -M_PI_2 +_progress * M_PI *2;
        UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:startA endAngle:endA clockwise:YES];
        
         CGContextAddPath(ctx, path.CGPath);
        
        CGContextStrokePath(ctx);
        
       
    }
    
    
    @end
    //
    //  ViewController.h
    //  进度条
    //
    //  Created by YaguangZhu on 15/9/9.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController
    
    
    @end
    
    
    
    //
    //  ViewController.m
    //  进度条
    //
    //  Created by YaguangZhu on 15/9/9.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import "ViewController.h"
    #import "HMProgressView.h"
    @interface ViewController ()
    @property (weak, nonatomic) IBOutlet HMProgressView *progressView;
    
    @end
    
    @implementation ViewController
    - (IBAction)valueChange:(UISlider *)sender {
        _progressView.progress = sender.value;
    }
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
  • 相关阅读:
    Windows Server 2016-配置Windows Defender防病毒排除项
    Windows Server 2016-增强IPAM
    第五讲:虚拟化架构、特点及优势
    第四讲:虚拟化概念及相关知识介绍
    第三讲:云计算的产生和特点
    第二讲:云分类及服务模式
    第一讲:云计算基础知识第一讲:云计算概念
    每天一个linux命令(56)--crontab命令
    每天一个linux命令(55)--at命令
    每天一个linux命令(54)--watch命令
  • 原文地址:https://www.cnblogs.com/zhuyaguang/p/4794994.html
Copyright © 2011-2022 走看看