詳解iPhone開發Quratz 2D學習

來源:互聯網
上載者:User

iPhone開發Quratz 2D學習是本文要介紹的內容,主要講解的是如何來使用Quratz 2D,一起來看詳細內容。

1.graphics context圖形上下文)是一個不透明的資料類型CGContextRef)。我們可以把graphics context想象成為一個繪圖目標。有幾種graphics context:bitmap graphics context,PDF graphics context,window graphics context,layer context。

2.IOS中獲得graphics context是在方法drawRect:中,調用方法UIGraphicsGetCurrentContext得到上下文。drawRect:方法不需要調用super

 
  1. CGContextRef c = UIGraphicsGetCurrentContext(); 

3.調用方法CGContextMoveToPoint開始一個新的路徑,

調用方法CGContextAddLineToPoint添加一個單一的線條。

4.When you want to construct a path in a graphics context, you signal Quartz by calling the function CGContextBeginPath . Next, you set the starting point for the first shape, or subpath, in the path by calling the function CGContextMoveToPoint. After you establish the first point, you can add lines, arcs, and curves to the path, keeping in mind the following:

Before you begin a new path, call the function CGContextBeginPath.

Lines, arcs, and curves are drawn starting at the current point. An empty path has no current point; you must call CGContextMoveToPoint to set the starting point for the first subpath or call a convenience function that implicitly does this for you.

When you want to close the current subpath within a path, call the function CGContextClosePath to connect a segment to the starting point of the subpath. Subsequent path calls begin a new subpath, even if you do not explicitly set a new starting point.

When you draw arcs, Quartz draws a line between the current point and the starting point of the arc.

Quartz routines that add ellipses and rectangles add a new closed subpath to the path.

You must call a painting function to fill or stroke the path because creating a path does not draw the path. See “Painting a Path” for detailed information.

小結:詳解iPhone開發Quratz 2D學習的內容介紹完了,希望通過本文的學習能對你有所協助!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.