简体   繁体   English

在Rect中绘制带有变换的图像

[英]Draw Image With Transform In Draw In Rect

I would Like to save UIImage with rotation in drawInRect . 我想通过旋转将UIImage保存在drawInRect
I am having four UImageView objects from which second and third has Rotation of 100 degree and 250 degree respectively. 我有四个UImageView对象, 第二个第三个对象分别具有100度250度的旋转。
So can anyone tell me how can I give rotation to those images which are inside UIImageView ? 那么谁能告诉我如何旋转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. 如果要保持250度旋转100度,请用250度替换100。

for 100 degrees 100度

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

for 250 degress 250度

(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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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