[英]Changing UIView (UIImageView specifically) frame programmatically not working
I load a UIImageView
with a certain height and width. 我加载具有一定高度和宽度的
UIImageView
。 after I initialise it, I would like to change it's height
programmatically. 初始化后,我想以编程方式更改它的
height
。 I am using the following code to do so, but it is not working. 我正在使用以下代码来执行此操作,但是它不起作用。
Note: The UIImageView
has constraints set on it. 注意:
UIImageView
设置了约束。
CGRect newframe = imageView.frame;
newframe.size.height= 500;
[imageView setFrame:newframe];
Calling setFrame
is not changing anything on the image. 调用
setFrame
不会更改图像上的任何内容。 What am I doing wrong? 我究竟做错了什么?
Thanks 谢谢
Modify the height constraint after initializing your UIImageView instead. 而是在初始化UIImageView之后修改高度约束。 See the second answer here for an example: Change frame programmatically with auto layout
例如,请参见第二个答案: 使用自动布局以编程方式更改框架
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.