iPhone UIView以编程方式设置阻止/定位支柱/弹簧 [英] iPhone UIView set resisting/position struts/springs programmatically

查看:75
本文介绍了iPhone UIView以编程方式设置阻止/定位支柱/弹簧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个接口,它使用.xib和以编程方式添加的视图中的元素。我正在尝试旋转视图。如果我指定左侧和底部的支柱,.xib元素会保持在位,但是以编程方式添加的元素会丢失相对于屏幕底部的位置。

I have an interface which uses elements from both an .xib and programmatically added views. I"m trying to rotate the views. The .xib elements stay in position if I assign left and bottom struts, but the programmatically added elements lose their position relative to the bottom of the screen.

如何以编程方式替换具有底部支柱的UIView的顶部支柱?我知道弹簧可以添加

uiview.autoresizingmask = ...;


推荐答案

autoresizingMask 属性也控制struts。听起来你想要这样做:

The autoresizingMask property also controls "struts". It sounds like you want to do this:

UIViewAutoresizing mask = myView.autoresizingMask;
mask &= ~UIViewAutoresizingFlexibleBottomMargin;
mask |= UIViewAutoresizingFlexibleTopMargin;
myView.autoresizingMask = mask;

这篇关于iPhone UIView以编程方式设置阻止/定位支柱/弹簧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆