gpt4 book ai didi

macos - NSView 自动调整大小以适应内容 View

转载 作者:行者123 更新时间:2023-12-03 16:23:41 25 4
gpt4 key购买 nike

CustomView *customView = [[CustomView alloc] init];
[self.window.contentView addSubview:customView];

当窗口调整大小时,如何使 customView.frame.size.height 始终等于 contentView.frame.size.height ,同时 customView.frame.size.width = 20; ?

最佳答案

Swift 版本,应用 autoresizingMask:

let customView = CustomView()
customView.autoresizingMask = [.width, .height]
self.window.contentView.addSubview(customView)

ref to options

关于macos - NSView 自动调整大小以适应内容 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13742684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com