Skip to Content
COCOA學習手冊--使用OBJECTIVE-C第三版
book

COCOA學習手冊--使用OBJECTIVE-C第三版

by Paris Buttfield-Addison, Jonathon Manning
June 2013
Intermediate to advanced
360 pages
6h 50m
Chinese
GoTop Information, Inc.
Content preview from COCOA學習手冊--使用OBJECTIVE-C第三版
第七章
在視圖中繪圖
對使用者展示各種圖形圖像(graphical image)的基本類別為視圖(view),圖形圖像指
的是按鈕、照片、文字之類的東西—使用者能夠看到的任何東西。
Cocoa UIKit 提供各種幾乎符合一切需要的控制項—你可以展示文字、圖像、按鈕等
等。不過,某些資料需要以特定方式繪製︰你可能想要針對資料繪製圖表,或者建立按
照你想要的方式展示的自訂按鈕類別。如果你正在建立繪圖 App,你必須能夠展示任何
類型的圖形內容,這表示,你的程式碼必須知道如何繪製它。
在這一章裡,你將學習如何建立自訂視圖物件(custom view object),對使用者展示任
何類型的圖像。你會學到如何使用高階 Objective-C API 來繪圖,並且建立按任何比例
縮放尺寸並且無損於品質的自訂視圖類別。最後,你將學到視網膜顯示(Retina)如何
運作在 iOS OS X 上。
繪圖機制如何運作
在我們開始撰寫程式碼繪製內容讓使用者觀看之前,先檢視一下繪圖機制如何在 OS X
iOS 上運作是很有幫助的。注意,相同的術語和技術對 OS X iOS 皆適用,但具體
API 則不相同。
在應用程式繪製圖形時,會先建立要在上面繪圖的畫布(canvas)。 Cocoa 稱此為圖形
下文
graphics
context
)。除了一般事項以外,圖形上下文定義畫布的尺寸,以及顏色
資訊如何被運用 ( 例如,你可以有黑白畫布、灰階畫布、16 位元顏色的畫布等等 )
103
104
|
第七章
一旦有了要在裡頭繪圖的圖形上下文,即可要求 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

網頁互動式資料視覺化:使用D3

網頁互動式資料視覺化:使用D3

Scott Murray
深入淺出代數

深入淺出代數

Tracey Pilone, Dan Pilone
自然语言处理实战:从入门到项目实践

自然语言处理实战:从入门到项目实践

Sowmya Vajjala, Bodhisattwa Majumder, Anuj Gupta, Harshit Surana

Publisher Resources

ISBN: 9789862768136