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
  • 相关阅读:
    线性时间排序算法
    【MSSQL】MDF、NDF、LDF文件的含义
    SQL表变量与临时表区别 + 非游标临时表遍历
    SQL Server 备份和还原全攻略
    S​Q​L​_​S​e​r​v​e​r​_​2​0​0​8​定​期​自​动​备​份​详​细​图​解
    Global.asax 文件是什么
    SQL 视图 局部变量 全局变量 条件语句 事务 触发器
    XP禁用了U盘和移动硬盘方法
    java实现 数据结构:链表、 栈、 队列、优先级队列、哈希表
    Mysql 存储过程和函数区别
  • 原文地址:https://www.cnblogs.com/zhuyaguang/p/4794994.html
Copyright © 2011-2022 走看看