更改UIView框架 [英] Change a UIView Frame
本文介绍了更改UIView框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在故事板
中设置了 UIView
并将其设为插座。
I have set a UIView
in my storyboard
and make it an outlet.
@property (nonatomic, weak) IBOutlet UIView *testView;
在 - (void)viewDidLoad
方法中,我想改变它的框架
In the - (void)viewDidLoad
method, I want to change its frame like this
CGRect frame = self.testView.frame;
frame.size.height = 2;
self.testView.frame = frame;
但它不起作用。有人可以告诉我原因吗?
But it does not work. Anybody can tell me why?
推荐答案
您可能启用了项目中的自动布局,如果是这样的话 setFrame
直接无效。 点击此处获取更多信息
You might enabled the autolayout in your project , if so the setFrame
straightly won't work . Check here for more info
解决方案:
- 如果你不喜欢自动布局不再需要了
- 使用autolayout检查上述链接。
这篇关于更改UIView框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文