Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone:How to dynamically set UIImage size , width , height and orientation?

Tags:

iphone

I want to develop functionality such that to set size , width , height & orientation of UIImage dynamically in iPhone so please tell me any link or any idea to develop this functionality.

like image 940
Nikunj Jadav Avatar asked Dec 27 '22 15:12

Nikunj Jadav


2 Answers

You can use 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
like image 93
Akshay Avatar answered Jan 25 '23 23:01

Akshay


I don't think anyone really understands your question, however:

size: (replace the width/height values wth your own)

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

orientation

float angleInDegrees = 90; // change this value to what you want
float angleInRadians = angleInDegrees * (M_PI/180);
myImageView.transform = CGAffineTransformMakeRotation(angleInRadians);
like image 30
Alex Coplan Avatar answered Jan 26 '23 00:01

Alex Coplan