我有一个 View 出现在其父 View 纵向模式的中心,我应该使用哪种autoresizemask以便它也以横向模式出现在中心。它的大小应该保持不变。我只希望它的原点在该点处自动移动,使其出现在中间。有什么需要帮助的吗?

我给了

[parentView setAutoResizesSubview:YES];

parentView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;

最佳答案

// horizontal
childView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;

// vertical
childView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;

// both
childView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;

关于ios - 正确的自动调整大小 mask ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12986130/

10-10 08:32