使用UIBezierPath绘制图形
2013-08-07 11:46
274 查看
如果效果图
具体 实现方法:
在UIView的子类中重写- (void)drawRect:(CGRect)rect;方法
- (void)drawRect:(CGRect)rect
{
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
[self.calloutBackgroundColorsetFill];
CGRect bezieRect = rect;
bezieRect.size.width -=kCalloutPinHeight;
//绘制右边三角曲线 开始
//圆角四边形
UIBezierPath *bezier = [UIBezierPathbezierPathWithRoundedRect:bezieRect
cornerRadius:4.0];
//添加右边三角形
[beziermoveToPoint:CGPointMake(bezieRect.size.width,
(bezieRect.size.height /
2) - 4.0)];
CGPoint firstLinePoint =
CGPointMake(rect.size.width, (bezieRect.size.height /2));
[bezieraddLineToPoint:firstLinePoint];
CGPoint secondLinePoint =
CGPointMake(bezieRect.size.width, (bezieRect.size.height /2)
+ 4.0);
[bezieraddLineToPoint:secondLinePoint];
//绘制右边三角曲线 结束
[bezierfill];
}
具体 实现方法:
在UIView的子类中重写- (void)drawRect:(CGRect)rect;方法
- (void)drawRect:(CGRect)rect
{
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
[self.calloutBackgroundColorsetFill];
CGRect bezieRect = rect;
bezieRect.size.width -=kCalloutPinHeight;
//绘制右边三角曲线 开始
//圆角四边形
UIBezierPath *bezier = [UIBezierPathbezierPathWithRoundedRect:bezieRect
cornerRadius:4.0];
//添加右边三角形
[beziermoveToPoint:CGPointMake(bezieRect.size.width,
(bezieRect.size.height /
2) - 4.0)];
CGPoint firstLinePoint =
CGPointMake(rect.size.width, (bezieRect.size.height /2));
[bezieraddLineToPoint:firstLinePoint];
CGPoint secondLinePoint =
CGPointMake(bezieRect.size.width, (bezieRect.size.height /2)
+ 4.0);
[bezieraddLineToPoint:secondLinePoint];
//绘制右边三角曲线 结束
[bezierfill];
}
相关文章推荐
- 使用 UIBezierPath 进行简单的图形绘制
- 使用UIBezierPath绘制图形
- iOS 使用UIBezierPath与CABasicAnimation绘制图形
- iOS 使用UIBezierPath 绘制图形
- 绘制几何图形——使用android.graphics类
- 在Dreamweaver下创建一个php文件并用正确使用php“绘图函数”进行绘制图形时,图形却无法显示
- Android UI SurfaceView的使用-绘制单个图型或多个图形
- VS2010 使用TeeChart绘图控件 - 之二 - 绘制图形(折线图,柱状图)
- 使用System.Draming 命名空间绘制图形
- 我使用过的Linux命令之dot - 绘制DOT语言脚本描述的图形
- Python使用matplotlib库绘制过图形
- 使用Canvas绘制几何图形
- 使用 UIBezierPath+CAShapeLayer 实现不在View层绘制自定义图形
- 使用CAShapeLayer与UIBezierPath画出想要的图形
- 高效程序员秘籍(7):使用Diagram Designer快速绘制流程图、UML等图形
- 使用matplotlib绘制三维图形
- 使用CAShapeLayer与UIBezierPath画出想要的图形
- iOS开发示例————使用CAShapeLayer&UIBezierPath绘制数据饼图
- 开始使用SmartDraw绘制开发中的各种图形
- 【JAVA语言程序设计基础篇】--图形-- 使用抽象方法绘制函数图形