Quartz 2D在ios中的使用簡述一 座標體系

2022-03-16 00:31:36 字數 786 閱讀 9472

一、座標體系

1.畫布延y軸下移height

2.對y軸做垂直翻轉

這2個步驟的**為:

1  cgcontexttranslatectm(context, 0

, height);

2 cgcontextscalectm(context, 1.0, -1.0);

測試**為:

//

**1- (void

)drawrect:(cgrect)rect

//

**2-(id

)initwithframe:(cgrect)frame

return

self;

}

2段**實現的效果一樣,**1並沒有做翻轉操作,那是因為uikit在uigraphicsgetcurrentcontext()得到的畫布已經幫我們適應好了uikit的座標體系。

iOS 使用Quartz 2D畫線

畫虛線需要用到函式 cgcontextsetlinedash 此函式需要四個引數 cgcontextref context uigraphicsgetcurrentcontext cgcontextbeginpath context cgcontextsetlinewidth context,2.0...

Quartz 2D在ios中的使用簡述二 建立畫布

在ios中使用quartz畫圖時,第一步就是要獲取畫布 圖形上下文 然後再畫布上做各種操作。先看下coregraphics.h這個標頭檔案,就可以知道能夠建立多少種上下文型別。include include include include include include include includ...

iOS 使用Quartz 2D畫虛線

畫虛線需要用到函式 cgcontextsetlinedash 此函式需要四個引數 cpp view plain copy print cgcontextref context uigraphicsgetcurrentcontext cgcontextbeginpath context cgconte...