IOS開發 畫直線

2021-07-11 22:17:34 字數 784 閱讀 4020

介紹兩種畫直線的方法:

(1)通過quartzcore

(2)通過uibezierpath

先建立乙個自定義view:

然後在匯入quartzcore框架:

然後在m檔案打出下面**,三種函式都是同樣的效果:

#import "zcview.h"

#import

@implementation

zcview

/*// only override drawrect: if you perform custom drawing.

// an empty implementation adversely affects performance during animation.

*/- (void)drawrect:(cgrect)rect

- (void)drawline1

- (void)drawline2

- (void)drawline3

@end

在drawrect函式裡面呼叫不同的函式就行了,效果如下:

iOS畫矩形 直線 文字的方法

7488353 cgpoint畫直線 cgcontextref ctx uigraphicsgetcurrentcontext cgcontextmovetopoint ctx,point1.x,point1.y cgcontextaddlinetopoint ctx,point2.x,point2...

iOS畫矩形 直線 文字的方法

cgpoint畫直線 cgcontextref ctx uigraphicsgetcurrentcontext cgcontextmovetopoint ctx,point1.x,point1.y cgcontextaddlinetopoint ctx,point2.x,point2.y 畫曲線 用...

畫直線演算法

畫直線演算法 前段時間做了一下光柵直線生成演算法的研究,並且在vc下實現了dda 演算法 bresenham 演算法 對稱演算法 兩步演算法 及四步演算法。這裡給個總結,希望和大家交流。主要研究的演算法主要有 dda演算法 bresenham 演算法 對稱演算法 兩步演算法 及四步演算法,此外還對自...