iPhone:如何动态设置UIImage的大小、宽度、高度和方向?

4
我希望开发这样的功能:在iPhone上动态设置UIImage的尺寸、宽度、高度和方向,请告诉我任何链接或开发该功能的想法。

动态地是什么意思?您希望用户能够使用手势进行更改吗? - Filip Radelic
你卡在哪里了?把你的代码给我们看看吧!你已经尝试过什么了? - dasdom
每当视图显示时动态更改图像。 - Nikunj Jadav
2个回答

9
您可以使用 UIImageView
//get the Image
UIImage *img = [UIImage imageNamed:@"img.png"];
//create a UIImageView
UIImageView *imageView = [[[UIImageView alloc] initWithImage:img] autorelease];
imageView.frame = CGRectMake(x, y, width, height); //set these variables as you want

1

我认为没有人真正理解你的问题,不过:

大小:(用自己的宽度/高度值替换)

myImageView.frame = CGRectMake(myImageView.frame.origin.x, myImageView.frame.origin.y,width,height);

方向

float angleInDegrees = 90; // change this value to what you want
float angleInRadians = angleInDegrees * (M_PI/180);
myImageView.transform = CGAffineTransformMakeRotation(angleInRadians);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接