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

时间:2011-08-09 10:24:05

标签: iphone

我想开发功能,以便设置尺寸,宽度,高度和尺寸。 UIImage在iPhone中动态定位,所以请告诉我任何链接或任何想法来开发此功能。

2 个答案:

答案 0 :(得分: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 :(得分: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);
相关问题