Re: [問題] 如何更新custom view 的繪圖內容
※ 引述《Jerrynet (我愛Hot_game板)》之銘言:
: 使用:Xcode 3.1 (Leopard)
: 語言:Objective-C
: 問題敘述:
: 我在custom view上畫一個漸層色上去,可是只要視窗大小改變有蓋到我的custom
: view 時,畫面會花掉= =
: 我看document裡面寫說 "Update a custom view to reflect changed content" 用:
: "Send a setNeedsDisplayInRect: or setNeedsDisplay: message to the view"
: 可是我沒有要改變我畫的內容啊,只是希望畫面變正常,就是有update這樣.
: 不知道要用哪個method呢?
使用setNeedsDisplay 就可以了.
: (不好意思我剛踏進蘋果程式設計,很多都不懂請多包涵> < )
: 第二個問題是,我在畫漸層的時候用NSGradient 的 drawInRect 這個方法,
: 它有個參數是NSRect,就是要畫漸層的地方吧?
: 那給它[customView rect] 和 [customView frame] 有什麼不同呢?
: 謝謝各位回答@@
你的Custom view是繼承自NSView嗎?
NSView似乎沒有rect這個message哦...
如果你指的是- (NSRect)bounds, 那你可以參考一下:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide
其中的View Geometry->Understanding a View's Frame and Bounds有很詳細的說明.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.229.47.151
推
04/30 23:31, , 1F
04/30 23:31, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):