二维绘图引擎:圆、半圆、弧线绘制
生活随笔
收集整理的這篇文章主要介紹了
二维绘图引擎:圆、半圆、弧线绘制
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
二維畫(huà)圖引擎-畫(huà)圓、半圓、弧線
// // QHCircle.m // 繪圖 //#import "QHCircle.h"@implementation QHCircle// Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. /*** 當(dāng)View第一次顯示的時(shí)候調(diào)用** @param rect*/- (void)drawRect:(CGRect)rect {// Drawing code//僅僅會(huì)調(diào)一次CGContextRef ctx = UIGraphicsGetCurrentContext();//2.畫(huà)1/4圓CGContextMoveToPoint(ctx, 100, 100);CGContextAddLineToPoint(ctx, 100, 150);CGContextAddArc(ctx, 100, 100, 50, -M_PI_2, M_PI, 1);CGContextClosePath(ctx);[[UIColor redColor]set];CGContextFillPath(ctx);drawArc();drawCircle();}void drawArc() {CGContextRef ctx = UIGraphicsGetCurrentContext();// 2.畫(huà)圓弧// x\y : 圓心// radius : 半徑// startAngle : 開(kāi)始角度// endAngle : 結(jié)束角度// clockwise : 圓弧的伸展方向(0:順時(shí)針, 1:逆時(shí)針)CGContextAddArc(ctx, 100, 100, 50, M_PI_2, M_PI, 0);CGContextFillPath(ctx); }void drawCircle() {CGContextRef ctx = UIGraphicsGetCurrentContext();//畫(huà)圓CGContextAddEllipseInRect(ctx, CGRectMake(50, 10, 100, 100));CGContextSetLineWidth(ctx, 10);CGContextStrokePath(ctx); } @end總結(jié)
以上是生活随笔為你收集整理的二维绘图引擎:圆、半圆、弧线绘制的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: docker对aufs触发的bug
- 下一篇: 单点登录cas常见问题(四) - tic