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