***

#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柱状图)的更多相关文章

  1. IOS第16天(5,Quartz2D雪花)

    *** #import "HMView.h" @interface HMView() { int count; } @property (nonatomic, assign) CG ...

  2. IOS第16天(3,Quartz2D饼图)

    **** #import "HMPieView.h" #import "UIColor+Random.h" @implementation HMPieView ...

  3. IOS第16天(2,Quartz2D下载进度条)

    *************自定义下载的view的方法 #import "HMProgressView.h" @interface HMProgressView() @propert ...

  4. IOS第16天(1,Quartz2D基本图像绘制)

    ***************基本图像绘制 画线 #import "HMLineView.h" @implementation HMLineView - (id)initWithF ...

  5. iOS根据16进制的色号来设置颜色,适合封装工具类

    iOS中有时候UI给的一个色号就像 #54e1b7 这个,而我们一般设置颜色都是根据RBG来设置的,所以这里需要把这个16进制的色号转为RGB值,这里我们就使用一下的方法来调用设置颜色. + (UIC ...

  6. [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 ...

  7. [iOS]把16进制(#871f78)颜色转换UIColor

    // // ViewController.m // text // // Created by 李东旭 on 16/1/22. // Copyright © 2016年 李东旭. All rights ...

  8. 【转】iOS中16进制转10进制

    原文网址:http://www.voidcn.com/blog/u012198553/article/p-4976772.html /// 将十六进制的字符串转化为NSData - (NSData ) ...

  9. iOS UI进阶-1.0 Quartz2D

    概述 Quartz 2D是一个二维绘图引擎,同时支持iOS和Mac系统.Quartz 2D能完成的工作: 绘制图形 : 线条\三角形\矩形\圆\弧等 绘制文字 绘制\生成图片(图像) 读取\生成PDF ...

随机推荐

  1. AngularJS学习之表单

    1.HTML控件:以下HTML input元素被称为HTML控件: **input元素 **select元素 **button元素 **textarea元素 2.AngularJS表单实例: < ...

  2. css:删除:×的效果

    常常要使用的显示删除效果: DEMO

  3. mark元素

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. JQuery validate验证 自定义

    http://www.w3cschool.cc/jquery/jquery-plugin-validate.html http://blog.163.com/zhao_jinggui/blog/sta ...

  5. CentOS 命令【备忘】

    1.查看物理cpu个数 grep 'physical id' /proc/cpuinfo | sort -u | wc -l 2.查看核心数量 grep 'core id' /proc/cpuinfo ...

  6. [Cocos2D-x For WP8]Label标签

    Label标签主要会用于在游戏中显示一些文字字符串类型的信息.那么在Cocos2D-x里面主要会有下面的一些创建标签的方式: 1.使用CCLabelTTF类生成系统文字的标签,编程语法如下: CCLa ...

  7. 推荐几本 Javascript 书籍

          初级读物: <JavaScript高级程序设计>:一本非常完整的经典入门书籍,被誉为JavaScript圣经之一,详解的非常详细,最新版第三版已经发布了,建议购买. <J ...

  8. Hibernate的第一次测试解析

    解析:此题目考查的是对Hibernate中交叉连接的理解.HQL支持SQL风格的交叉连接查询,交叉连接适用于两个类之间没有定义任何关联时.在where字句中,通过属性作为筛选条件,如统计报表数据.使用 ...

  9. [LintCode] Simplify Path 简化路径

    Given an absolute path for a file (Unix-style), simplify it. Have you met this question in a real in ...

  10. VMwareTools 安装(VMware Player)

    1. VMare Tools 按钮是灰化的,需要对虚拟机做如下设置:(在虚拟机没有启动的状态下进行)     1)Player(P)->管理->虚拟机设置->CD/DVD  选择:使 ...