UIBezierPath和CGContext类中的方法

本文详细介绍了iOS开发中UIBezierPath与CGContext的使用方法,包括设置线条宽度、添加线段、设置线段样式等核心绘图功能,并提供了创建不同形状的具体实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 UIBezierPath和CGContext类中的方法

    CGContextSetLineWidth(ctr, 10);
     // 即描写边线又填充
   
CGContextDrawPath(ctr, kCGPathFillStroke);


UIBezierPath和CGContext类中的方法

void CGContextSetLineWidth(CGContextRef c, CGFloat width); // 设置边线的宽度
void CGContextAddLineToPoint(CGContextRef c, CGFloat x, CGFloat y); // 添加一条线到某一个点
void CGContextSetLineCap(CGContextRef c, CGLineCap cap);  // 设置线段头尾部的样式
void CGContextSetLineJoin(CGContextRef c, CGLineJoin join); // 设置线段转折点的样式
void CGContextSetRGBStrokeColor(CGContextRef context, CGFloat red,
  CGFloat green, CGFloat blue, CGFloat alpha); 
// 设置颜色

+ (UIBezierPath *)bezierPath; // 创建UIBezierPath

+ (
UIBezierPath *)bezierPathWithRect:(CGRect)rect; // 创建一个四边形
void CGContextAddRect(CGContextRef c, CGRect rect) 

+ (
UIBezierPath *)bezierPathWithOvalInRect:(CGRect)rect; // 创建一个圆形
void CGContextAddEllipseInRect(CGContextRef context, CGRect rect)

+ (
UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius; // 创建弧形
void CGContextAddArc(CGContextRef c, CGFloat x, CGFloat y, CGFloat radius, CGFloat startAngle, CGFloat endAngle, int clockwise)

+ (
UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii; // 创建怪异的四边形
+ (
UIBezierPath *)bezierPathWithArcCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise; // 创建弧形,可以按照顺时针或者逆时针
+ (
UIBezierPath *)bezierPathWithCGPath:(CGPathRef)CGPath;

- (void)moveToPoint:(CGPoint)point; // 设置起点
- (
void)addLineToPoint:(CGPoint)point; // 添加一条线到某个点
- (
void)addArcWithCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise ; // 添加一个弧形,可以按照顺时针或者逆时针

- (
void)closePath; // 关闭路径(连接起点和最后一个点)
void CGContextClosePath(CGContextRef c)
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值