Re: [問題] NSView隨window縮放
※ 引述《wasihero ( )》之銘言:
: 請問一下
: OSX 10.6 SDK 如果不使用 IB 的情況下
: 要用程式碼配置一個 NSView 在 window的contentView下面
: 並且需要隨著window視窗放大縮小
: 程式這邊要去設定 NSView 的什麼屬性呢?
: 謝謝^^
http://goo.gl/KKLb0 [developer.apple.com]
類似 Interface Builder 的彈簧設定法是藉由改變 autoresizing mask 達成
http://goo.gl/uRqbF [developer.apple.com] 這裡列出了可以設定的值
用法是例如 [view setAutoresizingMask:(NSViewWidthSizable
| NSViewHeightSizable)];
這樣就代表寬與高都會隨 superview 一起改變
另外你可能會需要將 contentView 的 autoresizesSubviews 屬性設為 YES
或者, 如果你需要更進階的尺寸指定
也可以直接 override subview 的 -resizeWithOldSuperviewSize:
甚至 superview 的 -resizeSubviewsWithOldSize:
可以自行看文件瞭解一下這兩個 methods 與前述兩個屬性的關聯
--
Les grandes et les meilleurs tone from "Zadok the Priest"
Eine grosse stattliche Veranstaltung by F. Handel
THE MAIN EVENT! These are the men
Sie sind die Besten
"Champions League" by Tony Britten THESE ARE THE CHAMPIONS!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.81.146
推
10/08 12:35, , 1F
10/08 12:35, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章