[英]iPhone:How to dynamically set UIImage size , width , height and orientation?
我想開發功能,以便在iPhone中動態設置UIImage的大小,寬度,高度和方向,所以請告訴我任何鏈接或任何想法來開發此功能。
您可以使用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
但是,我認為沒有人真正理解你的問題:
尺寸:(用你自己的寬度/高度值替換)
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.