我試圖子視圖添加到窗口將被放在旁邊的對方,在窗口調整大小將會調整和明年留對方,我使用如何在代碼中添加彼此相鄰的子視圖?
NSWindow* window;
[window.contentFrame addSubView:newView];
我會添加代碼中的子視圖喜歡這樣做與約束API:
contentView addConstraint:[NSLayoutConstraint constraintWithItem:prevView
attribute:?
relatedBy:?
toItem:newView
attribute:NSLayoutAttributeLeft
multiplier:?
constant:?]];
先生,這是客觀-C不swift..and你的意思爲彼此相鄰多少?接下來呢? –
水平相鄰,每個子視圖放置在其前一個視圖旁邊 – shd
您在這裏要求提供「完整」教程。我建議你看看NSLayoutConstraints以及如何以編程方式使用它們。另外,不要將視圖添加到窗口,而只是添加到視圖控制器中的視圖 –