xcode 在 iPhone 开发中的视图上单独设置宽度和高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2864655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:22:36  来源:igfitidea点击:

set Width & Height alone on Views in iPhone Development

iphoneobjective-cxcode

提问by ChethanRao

Hey guys, I am working on an iPhone project where i need to change the width and height of a UIImageView dynamically. I have come across CGPointMake to change x & y positions alone, but what should i use for changing width & height alone??. There's something called CGSizeMake but i am not able to make it work. Can someone help...any idea abt this....???.. Thanks.

嘿伙计们,我正在开发一个 iPhone 项目,我需要动态更改 UIImageView 的宽度和高度。我遇到了 CGPointMake 来单独改变 x 和 y 位置,但是我应该用什么来单独改变宽度和高度??。有一种叫做 CGSizeMake 的东西,但我无法让它工作。有人可以帮忙...任何想法 abt 这....???.. 谢谢。

回答by emenegro

Try with this.

试试这个。

CGRect aFrame = image.frame;

aFrame.size.width = newWidth;
aFrame.size.height = newHeight;

image.frame = aFrame;