xcode -饼状进度条
界面搭建
创建一个画饼状的类 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 -饼状进度条的更多相关文章
- highcharts 折线,饼状,条状综合图
完整代码如下: <head> <meta http-equiv="Content-Type" content="text/html; charset=u ...
- css 3 制作水波状进度条
效果图如下 : 代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
- 第二百四十一节,Bootstrap进度条媒体对象和 Well 组件
第二百四十一节,Bootstrap进度条媒体对象和 Well 组件 学习要点: 1.Well 组件 2.进度条组件 3.媒体对象组件 本节课我们主要学习一下 Bootstrap 的三个组件功能:Wel ...
- ios swift 实现饼状图进度条,swift环形进度条
ios swift 实现饼状图进度条 // // ProgressControl.swift // L02MyProgressControl // // Created by plter on 7/2 ...
- PSP 进度条 柱状图 饼状图
9号 类别 开始时间 结束时间 间隔 净时间 燃尽图 8::00 8:20 0 20分钟 站立会议 8:20 8:50 0 30分钟 读构建之法 9:20 13:20 120分钟 120分钟 四人小组 ...
- HTML5-svg圆形饼状图进度条实现原理
<svg width="440" height="440" viewbox="0 0 440 440"> <circle ...
- css3实现饼状图进度及环形进度条
1 <!-- 饼图 --> <div class="pie"></div> <hr /> <!-- 环形图 --> &l ...
- [Xcode 实际操作]四、常用控件-(12)环形进度条控件的使用
目录:[Swift]Xcode实际操作 本文将演示环形进度条控件的使用. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit class Vi ...
- Qt之QRoundProgressBar(圆形进度条)
简述 QRoundProgressBar类能够实现一个圆形进度条,继承自QWidget,并且有和QProgressBar类似的API接口. 简述 详细说明 风格 颜色 字体 共有函数 共有槽函数 详细 ...
随机推荐
- SSM整合中遇到的不能扫描注解的bug
我的开发环境为: ubuntu14.04LTS 64bit; Spring Tool Suite 3.5.0.RELEASE Maven 3.2.3 SSM整合中遇到的不能扫描注解的bug 最终解决 ...
- 给ecshop后台增加管理功能页面
给ecshop后台增加管理功能页面 比如我们增加一个统计报表叫做 物流费用统计报表 放在后台“报表统计”栏目中 具体操作步骤: 第一步,我们要添加一个菜单到后台,然后设置语言项,最后设置权限,这样,后 ...
- javascript第十二课array数组
数组的声明方式: var add=new array(元素1,元素2,元素3......); 推荐的数组声明方式: var add=[元素1,元素2,元素3,元素4....]; 数组遍历方式: 循环遍 ...
- android handler机制和Timer采用
Timer主要用于创建一个任务来定期运行. 创建继承Task该任务等级.即任务每次跑. private class MyTask extends TimerTask { @Override publi ...
- JavaScript 工作必知(九)function 说起 闭包问题
大纲 Function Caller 返回函数调用者 Callee 调用自身 作用域 闭包 function 函数格式 function getPrototyNames(o,/*optional*/ ...
- SQL 语句中按照in语句原有的顺序进行排序
Access: ,,) order by instr(',1,5,3,',','&;id&;',') MSSQL: ,,) )))+',',',1,5,3,') MySQL: ,,) ...
- Can't load IA 32-bit .dll on a AMD 64-bit platform
在myeclipse中使用的,tomcat异常:java.lang.UnsatisfiedLinkError: D:\JAVA\ApacheTomcat\bin\tcnative-1.dll: Can ...
- select函数的简单使用
server: socket()->bind()->listen()->FD_SET()->select()->accept()->FD_SET()->sel ...
- tomcat 设置session 时间
Tomcat Session过期时间 Tomcat采用数据库连接池技术,当用户在一定时间不对数据库有操作时间后,就自动关闭这个连接,这是为了更好的利用资源,防止浪费宝贵的数据库连接资源. 可以采用如 ...
- Atom power-mode
最近看到很多大牛都在用这个酷炫狂拽掉渣天的插件,于是就默默地git了一波.实际结果就是机械键盘加上砰砰砰砰,根本停不下来有没有. 建议(ˉ(∞)ˉ) :视力2.0的同学不建议使用,眼瞎的同学用就用吧, ...