界面搭建

创建一个画饼状的类  eatView 集成UIView

#import "eatView.h"

@implementation eatView

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
//创建一个园的风格数组
NSArray * arr = @[@,@,@,@,@,@,@,@,@,@]; //计算园的中心点
CGPoint center = CGPointMake(rect.size.width * 0.5, rect.size.height * 0.5);
//园的半径
CGFloat radius = rect.size.width * 0.5 ;
//开始位置
CGFloat startA = ;
//结束位置
CGFloat endA = ;
CGFloat angle = ;
//设置uiView的背景颜色
self.backgroundColor=[UIColor clearColor];
//遍历园等分的数组
for (NSNumber *num in arr) {
//计算开始位置
startA = endA;
//计算弧度
angle = num.intValue / 100.0 * M_PI *;
//结束位置
endA =startA + angle;
//创建画笔
UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:startA endAngle:endA clockwise:YES];
//画一条连接中心的线
[path addLineToPoint:center];
//设置随机颜色
[[self randomColor]set];
[path fill];
}
//创建一个定时器
CADisplayLink * link =[CADisplayLink displayLinkWithTarget:self selector:@selector(click)];
//加入主运行时
[link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
//创建一个定时器
// [NSTimer scheduledTimerWithTimeInterval:1/50.0 target:self selector:@selector(click) userInfo:nil repeats:YES];
}
/**
生产随机颜色
*/
- (UIColor *)randomColor{
return [UIColor colorWithRed:arc4random_uniform()/255.0 green:arc4random_uniform()/255.0 blue:arc4random_uniform()/255.0 alpha:];
}
/**
重绘图行
*/
-(void)click{
[self setNeedsDisplay];
} @end

脱线 一根UITextField 另一根UIView

@property (weak, nonatomic) IBOutlet UITextField *textNum;

@property (weak, nonatomic) IBOutlet UIView *beginView;

拖线 UIButton 点击方法  - (IBAction)beginGoBtn:(id)sender

#import "ViewController.h"

#import "eatView.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textNum;
@property (weak, nonatomic) IBOutlet UIView *beginView; @end @implementation ViewController - (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.
} - (IBAction)beginGoBtn:(id)sender {
//释放加载过得UIview 不然又内存问题
for (UIView * vol in self.beginView.subviews) {
[vol removeFromSuperview];
}
//关闭键盘
[self.view endEditing:YES];
int count=self.textNum.text.intValue;
for (int i=0; i<count; i++) {
eatView * eatV = [[eatView alloc]init]; // 按钮尺寸
CGFloat optionW = 50;
CGFloat optionH = 50;
// 按钮之间的间距
CGFloat margin = 5;
// 控制器view的宽度
CGFloat viewW = self.beginView.frame.size.width;
// 总列数
int totalColumns = 6;
// 最左边的间距 = 0.5 * (控制器view的宽度 - 总列数 * 按钮宽度 - (总列数 - 1) * 按钮之间的间距)
CGFloat leftMargin = (viewW - totalColumns * optionW - margin * (totalColumns - 1)) * 0.5;
int col = i % totalColumns;
// 按钮的x = 最左边的间距 + 列号 * (按钮宽度 + 按钮之间的间距)
CGFloat optionX = leftMargin + col * (optionW + margin);
int row = i / totalColumns;
// 按钮的y = 行号 * (按钮高度 + 按钮之间的间距)
CGFloat optionY = row * (optionH + margin);
eatV.frame = CGRectMake(optionX, optionY, optionW, optionH); [self.beginView addSubview:eatV];
} } @end

效果图:

xcode -饼状进度条的更多相关文章

  1. highcharts 折线,饼状,条状综合图

    完整代码如下: <head> <meta http-equiv="Content-Type" content="text/html; charset=u ...

  2. css 3 制作水波状进度条

    效果图如下 : 代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  3. 第二百四十一节,Bootstrap进度条媒体对象和 Well 组件

    第二百四十一节,Bootstrap进度条媒体对象和 Well 组件 学习要点: 1.Well 组件 2.进度条组件 3.媒体对象组件 本节课我们主要学习一下 Bootstrap 的三个组件功能:Wel ...

  4. ios swift 实现饼状图进度条,swift环形进度条

    ios swift 实现饼状图进度条 // // ProgressControl.swift // L02MyProgressControl // // Created by plter on 7/2 ...

  5. PSP 进度条 柱状图 饼状图

    9号 类别 开始时间 结束时间 间隔 净时间 燃尽图 8::00 8:20 0 20分钟 站立会议 8:20 8:50 0 30分钟 读构建之法 9:20 13:20 120分钟 120分钟 四人小组 ...

  6. HTML5-svg圆形饼状图进度条实现原理

    <svg width="440" height="440" viewbox="0 0 440 440"> <circle ...

  7. css3实现饼状图进度及环形进度条

    1 <!-- 饼图 --> <div class="pie"></div> <hr /> <!-- 环形图 --> &l ...

  8. [Xcode 实际操作]四、常用控件-(12)环形进度条控件的使用

    目录:[Swift]Xcode实际操作 本文将演示环形进度条控件的使用. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit class Vi ...

  9. Qt之QRoundProgressBar(圆形进度条)

    简述 QRoundProgressBar类能够实现一个圆形进度条,继承自QWidget,并且有和QProgressBar类似的API接口. 简述 详细说明 风格 颜色 字体 共有函数 共有槽函数 详细 ...

随机推荐

  1. 论山寨手机与Android联姻 【8】 自己动手做XP手机

    2010年1月20日,ViewSonic在北京发布了一款真正意义的电脑手机VCP08.根据商家的宣传,VCP08之所以能够被称为真正的电脑手机,是因为“该机做到了把真正的WindowsXP操作系统嵌入 ...

  2. MATLAB中文论坛帖子整理(GUI)

    MATLAB中文论坛帖子整理(GUI) 目   录  1.GUI新手之——教你读懂GUI的M文件... 10 2.GUI程序中改变current directory引起的问题... 15 3.GUI中 ...

  3. ckeditor编辑器在java项目中配置

    一.基本使用: 1.所需文件架包 A. Ckeditor基本文件包,比如:ckeditor_3.6.2.zip 下载地址:http://ckeditor.com/download 2.配置使用 A.将 ...

  4. poj1423---求一个大数的位数方法,我猜网站上统计输入字符少于多少位的那个算法

    法一:对一个数求它的对数,+1取整为其位数 问题转化为int (log10(N!)+1),对数性质log10(N!)=log10(N)+log10(N-1)+...+log10(1) /*用log10 ...

  5. AjaxPro.dll,asp.net 前台js调用后台方法(无刷新)

    1.什么是Ajax Ajax是异步Javascript和XML(Asynchronous JavaScript and XML)的英文缩写."Ajax"这个名词的发明人是Jesse ...

  6. Mysql两种存储引擎的优缺点

    MyISAM引擎是一种非事务性的引擎,提供高速存储和检索,以及全文搜索能力,适合数据仓库等查询频繁的应用.MyISAM中,一个table实际保存为三个文件,.frm存储表定义,.MYD存储数据,.MY ...

  7. asp.net中自定义验证控件

    在windows2003中,可能iis版本太底,不支持TextBox的类型设为Number类型,所以会报错,所以去掉后直接用验证控件来控制必须输入数字好了. <asp:RegularExpres ...

  8. ORACLE EBS BOM 展开(使用标准程序bompexpl.exploder_userexit展开)

    create or replace package cux_bom_pub is PROCEDURE bom_expand_to_temp( p_organization_id number, p_i ...

  9. 《OS X Mountain Lion》 读书杂记

    OS X是一个类UNIX操作系统,由底层的Darwin和上层的OS X应用程序框架(Cocoa, Carbon, Quartz等)及Aqua用户界面组成.其中Darwin是一个开源.完整的POSIX- ...

  10. Linux学习之给指定用户发邮件

    发送邮件 进入 mail 程序后的操作都很简单,但是可以不进入 mail 的 & 操作提示符界面,下面举几个实用例子: 1.给 snailwarrior@qq.com 发信 [root@pps ...