IOS第16天(4,Quartz2D柱状图)
***
#import "HMBarView.h"
#import "UIColor+Random.h"
@implementation HMBarView - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
} // Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
NSArray *data = @[@,@,@];
int count = data.count; CGFloat w = rect.size.width / ( * count - );
CGFloat h = ;
CGFloat x = ;
CGFloat y = ;
CGFloat viewH = rect.size.height;
// 1.获取上下文
CGContextRef ctx = UIGraphicsGetCurrentContext(); for (int i = ; i < count; i++) {
h = viewH * [data[i] intValue] / 100.0;
x = * w * i;
y = viewH - h;
// 2.拼接路径
UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(x, y, w, h)]; // 3.添加路径到上下文
CGContextAddPath(ctx, path.CGPath); [[UIColor randomColor] set]; // 4.渲染
CGContextFillPath(ctx);
} } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self setNeedsDisplay];
} @end
IOS第16天(4,Quartz2D柱状图)的更多相关文章
- IOS第16天(5,Quartz2D雪花)
*** #import "HMView.h" @interface HMView() { int count; } @property (nonatomic, assign) CG ...
- IOS第16天(3,Quartz2D饼图)
**** #import "HMPieView.h" #import "UIColor+Random.h" @implementation HMPieView ...
- IOS第16天(2,Quartz2D下载进度条)
*************自定义下载的view的方法 #import "HMProgressView.h" @interface HMProgressView() @propert ...
- IOS第16天(1,Quartz2D基本图像绘制)
***************基本图像绘制 画线 #import "HMLineView.h" @implementation HMLineView - (id)initWithF ...
- iOS根据16进制的色号来设置颜色,适合封装工具类
iOS中有时候UI给的一个色号就像 #54e1b7 这个,而我们一般设置颜色都是根据RBG来设置的,所以这里需要把这个16进制的色号转为RGB值,这里我们就使用一下的方法来调用设置颜色. + (UIC ...
- [Draft]iOS.Architecture.16.Truth-information-flow-and-clear-responsibilities-immutability
Concept: Truth, Information Flow, Clear Responsibilities and Immutability 1. Truth 1.1 Single Source ...
- [iOS]把16进制(#871f78)颜色转换UIColor
// // ViewController.m // text // // Created by 李东旭 on 16/1/22. // Copyright © 2016年 李东旭. All rights ...
- 【转】iOS中16进制转10进制
原文网址:http://www.voidcn.com/blog/u012198553/article/p-4976772.html /// 将十六进制的字符串转化为NSData - (NSData ) ...
- iOS UI进阶-1.0 Quartz2D
概述 Quartz 2D是一个二维绘图引擎,同时支持iOS和Mac系统.Quartz 2D能完成的工作: 绘制图形 : 线条\三角形\矩形\圆\弧等 绘制文字 绘制\生成图片(图像) 读取\生成PDF ...
随机推荐
- 内核终端判断,微信?QQ?ipad?IE?移动?Google?opera……
$(document).ready(function(){ //判断访问终端 var browser={ versions:function(){ var u = navigator.userAgen ...
- canvas 3D运动球效果
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- 设置随机启动--《用delphi开发共享软件》-15.1任务管理器
在设置窗体中 chkAutoStart: TCheckBox; 在设置窗体中 chkAutoStart: TCheckBox; procedure TFrmSetup.FormCreate(Sende ...
- view not attached to windows manager与This Toast was not created with Toast.makeText()
http://blog.sina.com.cn/s/blog_474928c90100x871.html public class Ex04_1Activity extends Activ ...
- Android中使用反应式编程RxJava
GitHut 地址: https://github.com/ReactiveX/RxAndroid (1)RxJava简介: RxJava 是一个在Java虚拟机上实现的响应式扩展库:提供了基于obs ...
- 关于NSNotificationCenter消息通信用法
NSNotificationCenter主要用于广播消息到多个监听着,其传统用法 - (void)viewDidLoad { [super viewDidLoad]; [[NSNotification ...
- 【Oracle】ORA-28000: the account is locked-的解决办法
ORA-28000: the account is locked第一步:使用PL/SQL,登录名为system,数据库名称不变,选择类型的时候把Normal修改为Sysdba;第二步:选择myjob, ...
- 【bzoj2179】FFT快速傅立叶 FFT模板
2016-06-01 09:34:54 很久很久很久以前写的了... 今天又比较了一下效率,貌似手写复数要快很多. 贴一下模板: #include<iostream> #include& ...
- PHP 进行数据庫对比工具
<?php /** * author jackluo * net.webjoy@gmail.com */ class IMysqlDiff { private $master,$slave; p ...
- [LintCode] Nuts & Bolts Problem 螺栓螺母问题
Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...