作者atst (电脑无法阻止人类做蠢事)
看板MacDev
标题Re: [问题] 如何更新custom view 的绘图内容
时间Wed Apr 30 23:04:13 2008
※ 引述《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
1F:推 Jerrynet:阿没错~是bounds, 谢谢回答~来去看文件~@@ 04/30 23:31