Re: [問題] 如何更新custom view 的繪圖內容

看板MacDev作者 (電腦無法阻止人類做蠢事)時間16年前 (2008/04/30 23:04), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《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
阿沒錯~是bounds, 謝謝回答~來去看文件~@@
04/30 23:31, 1F
文章代碼(AID): #1868fk4n (MacDev)
文章代碼(AID): #1868fk4n (MacDev)