我正在尝试在导航栏的子类和分段控件上设置自动调整大小。我需要在代码中执行此操作,而不是界面生成器。
我想要与此接口(interface)设置等效的代码。
编辑:
我试过这个,但它不起作用。
[self.segmentedControl setAutoresizingMask: UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
最佳答案
The flexible width and height constants [
UIViewAutoresizingFlexibleHeight
andUIViewAutoresizingFlexibleWidth
] from the preceding figure have the same behavior as the width and size indicators in the Autosizing controls diagram. However, the behavior and use of margin indicators is effectively reversed. In Interface Builder, the presence of a margin indicator means that the margin has a fixed size and the absence of the indicator means the margin has a flexible size.
您希望底部、左侧和右侧边距固定(这是默认值),而顶部边距灵活。试试这个:
[self.segmentedControl setAutoresizingMask: UIViewAutoresizingFlexibleTopMargin];
关于iPhone 设置自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10376464/