我執行使用的UIImageView縮放,旋轉,在我的項目, 我現在面臨的問題在放大和旋轉圖像後縮小,的UIImageView旋轉和縮放在iPhone SDK
這裏是我的代碼如下:
在.h文件中@interface ViewController : UIViewController{
float degrees;
float height;
float width;
float moveLeft;
float moveRight;
}
@property(nonatomic,retain)UIImageView *imageView;
-(IBAction)rotationLeft:(id)sender;
-(IBAction)rotationRight:(id)sender;
-(IBAction)zoomIn:(id)sender;
-(IBAction)zoomOut:(id)sender;
-(IBAction)moveLeft:(id)sender;
-(IBAction)moveRight:(id)sender;
在.m文件
- (void)viewDidLoad
{
[super viewDidLoad];
height=50;
width=50;
degrees=20;
moveLeft=20;
moveRight=20;
imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"1.png"]];
imageView.frame=CGRectMake(100, 100,width, height);
[self.view addSubview:imageView];
// Do any additional setup after loading the view, typically from a nib.
}
-(IBAction)rotationLeft:(id)sender{
//the value in degrees
imageView.transform = CGAffineTransformMakeRotation(degrees*M_PI/180);
degrees=degrees+25;
}
-(IBAction)rotationRight:(id)sender{
//the value in degrees
degrees=degrees-25;
imageView.transform = CGAffineTransformMakeRotation(degrees*M_PI/180);
}
-(IBAction)zoomIn:(id)sender{
height=height-15;
width=width-15;
imageView.frame=CGRectMake(100, 100,width, height);
}
-(IBAction)zoomOut:(id)sender{
height=height+15;
width=width+15;
imageView.frame=CGRectMake(100, 100,width, height);
}
請參閱附件圖片以供參考。
它的縮放與否? – Hiren 2012-07-19 10:53:55
其縮放但圖像像給定的參考圖像一樣伸展。 – VSN 2012-07-19 11:01:09