在Interface Builder
中,您有约束告诉应用程序如何在设备旋转时重新绘制屏幕。
有没有办法以编程方式设置这些?
您需要设置autoresizingMask
视图。
它指定视图如何自动调整大小。(这是您在 中设置的Interface Builder
。)
enum {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
typedef NSUInteger UIViewAutoresizing;