Re: [問題] NSView隨window縮放

看板MacDev作者 (←這人是超級笨蛋)時間12年前 (2012/10/08 11:26), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《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
文章代碼(AID): #1GSaVlbl (MacDev)
討論串 (同標題文章)
文章代碼(AID): #1GSaVlbl (MacDev)