简体   繁体   中英

Draw Image With Transform In Draw In Rect

I would Like to save UIImage with rotation in drawInRect .
I am having four UImageView objects from which second and third has Rotation of 100 degree and 250 degree respectively.
So can anyone tell me how can I give rotation to those images which are inside UIImageView ?

I hope it will help you to solve your problem,

for 100 degree rotation if you want to keep for 250 degree please replace 100 with 250 degrees.

for 100 degrees

(UIImageview *).transform = CGAffineTransformMakeRotation(1.744);

for 250 degress

(UIImageview *).transform = CGAffineTransformMakeRotation(4.36);

This code is as per your requirement

 UIGraphicsBeginImageContext( newSize );
[bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
//I want Rotation for second and third Image//
 [secondImage drawInRect:CGRectMake(0, 0, 110, 300)]; 
 secondImage.transform = CGAffineTransformMakeRotation(1.744);

[thirdImage drawInRect:CGRectMake(0, 0, 110, 300)]; 
thirdImage.transform = CGAffineTransformMakeRotation(4.36);
[fourthImage drawInRect:CGRectMake(0,0,fourthImage.size.width ,fourthImage.size.height )]; 

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM