iOS动画之iOS UIBezierPath类 介绍
感谢:http://blog.csdn.net/crayondeng/article/details/11093689
使用UIBezierPath类可以创建基于矢量的路径,这个类在UIKit中。此类是Core Graphics框架关于path的一个封装。使用此类可以定义简单的形状,如椭圆或者矩形,或者有多个直线和曲线段组成的形状。
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色 UIBezierPath* aPath = [UIBezierPath bezierPath];
aPath.lineWidth = 5.0; aPath.lineCapStyle = kCGLineCapRound; //线条拐角
aPath.lineJoinStyle = kCGLineCapRound; //终点处理 // Set the starting point of the shape.
[aPath moveToPoint:CGPointMake(100.0, 0.0)]; // Draw the lines
[aPath addLineToPoint:CGPointMake(200.0, 40.0)];
[aPath addLineToPoint:CGPointMake(, )];
[aPath addLineToPoint:CGPointMake(40.0, )];
[aPath addLineToPoint:CGPointMake(0.0, 40.0)];
[aPath closePath];//第五条线通过调用closePath方法得到的 [aPath stroke];//Draws line 根据坐标点连线
}


+ (UIBezierPath *)bezierPathWithRect:(CGRect)rect
demo代码:
- (void)drawRect:(CGRect)rect
{
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色 UIBezierPath* aPath = [UIBezierPath bezierPathWithRect:CGRectMake(, , , )]; aPath.lineWidth = 5.0;
aPath.lineCapStyle = kCGLineCapRound; //线条拐角
aPath.lineJoinStyle = kCGLineCapRound; //终点处理 [aPath stroke];
}
+ (UIBezierPath *)bezierPathWithOvalInRect:(CGRect)rect
+ (UIBezierPath *)bezierPathWithArcCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise
Parameters
center
Specifies the center point of the circle (in the current coordinate system) used to define the arc.
radius
Specifies the radius of the circle used to define the arc.
startAngle
Specifies the starting angle of the arc (measured in radians).
endAngle
Specifies the end angle of the arc (measured in radians).
clockwise
The direction in which to draw the arc.
Return Value
A new path object with the specified arc.

#define pi 3.14159265359
#define DEGREES_TO_RADIANS(degrees) ((pi * degrees)/ 180)
- (void)drawRect:(CGRect)rect
{
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色 UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(, )
radius:
startAngle:
endAngle:DEGREES_TO_RADIANS()
clockwise:YES]; aPath.lineWidth = 5.0;
aPath.lineCapStyle = kCGLineCapRound; //线条拐角
aPath.lineJoinStyle = kCGLineCapRound; //终点处理 [aPath stroke];
}

 
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint
Parameters
endPoint
The end point of the curve.
controlPoint
The control point of the curve.

demo代码:
- (void)drawRect:(CGRect)rect
{
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色 UIBezierPath* aPath = [UIBezierPath bezierPath]; aPath.lineWidth = 5.0;
aPath.lineCapStyle = kCGLineCapRound; //线条拐角
aPath.lineJoinStyle = kCGLineCapRound; //终点处理 [aPath moveToPoint:CGPointMake(, )]; [aPath addQuadCurveToPoint:CGPointMake(, ) controlPoint:CGPointMake(, )]; [aPath stroke];
}

- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2
Parameters
endPoint
The end point of the curve.
controlPoint1
The first control point to use when computing the curve.
controlPoint2
The second control point to use when computing the curve.

demo代码:
- (void)drawRect:(CGRect)rect
{
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色 UIBezierPath* aPath = [UIBezierPath bezierPath]; aPath.lineWidth = 5.0;
aPath.lineCapStyle = kCGLineCapRound; //线条拐角
aPath.lineJoinStyle = kCGLineCapRound; //终点处理 [aPath moveToPoint:CGPointMake(, )]; [aPath addCurveToPoint:CGPointMake(, ) controlPoint1:CGPointMake(, ) controlPoint2:CGPointMake(, )]; [aPath stroke];
}

iOS动画之iOS UIBezierPath类 介绍的更多相关文章
- iOS UIBezierPath类 介绍
		
使用UIBezierPath类可以创建基于矢量的路径,这个类在UIKit中.此类是Core Graphics框架关于path的一个封装.使用此类可以定义简单的形状,如椭圆或者矩形,或者有多个直线和 ...
 - IOS 动画专题   --iOS核心动画
		
iOS开发系列--让你的应用“动”起来 --iOS核心动画 概览 通过核心动画创建基础动画.关键帧动画.动画组.转场动画,如何通过UIView的装饰方法对这些动画操作进行简化等.在今天的文章里您可以看 ...
 - 【Android工具类】用户输入非法内容时的震动与动画提示——EditTextShakeHelper工具类介绍
		
转载请注明出处:http://blog.csdn.net/zhaokaiqiang1992 当用户在EditText中输入为空或者是数据异常的时候,我们能够使用Toast来提醒用户,除此之外,我们还能 ...
 - iOS 使用UIBezierPath类实现随手画画板
		
在上一篇文章中我介绍了 UIBezierPath类 介绍 ,下面这篇文章介绍一下如何通过这个类实现一个简单的随手画画板的简单程序demo,功能包括:划线(可以调整线条粗细,颜色),撤销笔画,回撤笔画, ...
 - UIBezierPath 类的使用
		
使用UIBezierPath类可以创建基于矢量的路径,这个类在UIKit中.此类是Core Graphics框架关于path的一个封装.使用此类可以定义简单的形状,如椭圆或者矩形,或者有多个直线和曲线 ...
 - iOS 动画篇 (二) CAShapeLayer与CoreAnimation结合使用
		
接上一篇博客 iOS 动画篇(一) Core Animation CAShapeLayer是CALayer的一个子类,使用这个类能够很轻易实现曲线的动画. 先来一个折线动画效果: 示例代码: //1. ...
 - IOS动画(Core Animation)总结 (参考多方文章)
		
一.简介 iOS 动画主要是指Core Animation框架.官方使用文档地址为:Core Animation Guide. Core Animation是IOS和OS X平台上负责图形渲染与动画的 ...
 - iOS 动画笔记 (一)
		
你也肯定喜欢炫酷的动画! 在APP中,动画就是一个点睛之笔!可以给用户增加一些独特的体验感,估计也有许多的和我一样的,看着那些觉得不错的动画,也就只能流口水的孩子,毕竟可能不知道从哪里下手去写!动画学 ...
 - iOS 动画Animation - 5:UIBezier
		
首先说明:这是一系列文章,參考本专题下其它的文章有助于你对本文的理解. 在之前的bolg中大家会发现总是会出现UIBezier,可是我也没有做过多介绍,今天就集中介绍一下UIBezier.首先.UIB ...
 
随机推荐
- 笔记-JavaWeb学习之旅15
			
Filter:过滤器 概念:当访问服务器的资源是,过滤器可以将请求拦截下来,完成一些特殊的功能 快速入门: 步骤: 定义一个类,实现接口Filter 复写方法 配置拦截路径 package com.d ...
 - centOS7.5上部署server jre1.8.0_192 tomcat-8.5.35 mysql-8.0.13
 - Linux下处理^M字符
			
很多时候windows环境中编辑过的文件,在Linux下经常会出现^M字符,可以通过以下方式处理该字符. vim命令打开文件,然后在vim命令模式下输入以下内容: :%s/^M//g特别注意:注意^M ...
 - jquery扩展方法详解
			
http://www.jb51.net/article/51079.htm https://www.cnblogs.com/xuxiuyu/p/5989743.html ---更详细
 - D. Mike and distribution  首先学习了一个玄学的东西
			
http://codeforces.com/contest/798/problem/D D. Mike and distribution time limit per test 2 seconds m ...
 - C# 实现本地化日志管理
			
1.新建一个类库解决方案 CommnoLog 2.新建两个文件夹 2.1FileUtil.cs 代码如下 public static class FileUtil { /// <summary ...
 - 关于Linux系统启动时出现UVD not responding, Trying to reset the vcpu问题的解决
			
本人的老古董笔记本!不知道什么时候显卡烧坏了 每次启动Linux的时候就会出现错误,信息如下: UVD not responding, trying to reset the VCPU! 讲道理,显卡 ...
 - FAST FW150R软件版本升级解决一些网页无法加载问题
			
家里用的移动宽带,通过无线路由器无线上网.上taobao.天猫都很快,但是一上京东.苏宁易购界面加载很慢,界面无法显示,怀疑是无线路由问题,然后直接通过网线相连接,发现问题消失,决定对无线路由软件版本 ...
 - I Have a Dream(我有一个梦想)
			
I Have a Dream by Martin Luther King, Jr. I am happy to join with you today in what will go down in ...
 - 评价PE基金绩效的常用指标
			
作为信息系统,辅助管理层决策是重要的功能之一.前文介绍了PE基金管理系统的建设,对PE业务的运转有了一些了解,但没有介绍如何评价PE基金的绩效,而这是管理层作出重大决策的主要依据之一.PE基金本质也是 ...