是否可以为UIView的autoresizingMask属性提供数组?我之所以要这样做,是因为我有一些条件来决定要将哪些autoresizingMask属性添加到我的视图中。
因此,不是简单地使用:
self.view.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;我想做一些类似的事情:
if (addMargin) {
[items addObject:UIViewAutoresizingFlexibleRightMargin];
}
if (addWidth) {
[items addObject:UIViewAutoresizingFlexibleWidth];
}
// Add to property
self.view.autoresizingMask = items;所以我基本上想有条件地设置这个属性的项。
发布于 2011-08-19 01:23:26
这是一个位掩码。只需按位-或将其与您想要的一个。
if(addMargin)
self.view.autoresizingMask |= UIViewAutoresizingFlexibleRightMargin;
if(addWidth)
self.view.autoresizingMask |= UIViewAutoresizingFlexibleWidth;要重置遮罩,可以将其设置为0,或者如果要删除特定属性,可以将其取反并按位-以及使用它的遮罩:
if(removeMargin)
self.view.autoresizingMask &= ~UIViewAutoresizingFlexibleRightMargin;发布于 2011-08-19 01:23:09
自动调整大小只是一个位掩码。
UIViewAutoresizing resize = 0;
if (addMargin) {
resize = resize | UIViewAutoresizingFlexibleRightMargin;
}
if (addWidth) {
resize = resize | UIViewAutoresizingFlexibleWidth;
}
self.view.autoresizingMask = resizehttps://stackoverflow.com/questions/7111466
复制相似问题