【问题标题】:Draw Image With Transform In Draw In Rect在矩形中绘制带有变换的图像
【发布时间】:2013-07-28 21:19:26
【问题描述】:

我想在drawInRect 中旋转保存UIImage
我有四个 UImageView 对象,其中 secondthird 分别具有 100 度250 度 的旋转.
那么谁能告诉我如何对UIImageView 中的那些图像进行旋转?

【问题讨论】:

    标签: iphone ios uiimageview uiimage core-graphics


    【解决方案1】:

    希望能帮助你解决问题,

    对于 100 度旋转,如果要保持 250 度,请将 100 替换为 250 度。

    100 度

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

    250 度

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

    此代码符合您的要求

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

    【讨论】:

    • 这是我的代码.. UIGraphicsBeginImageContext(newSize); [bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; //我想要第二个和第三个图像的旋转// [secondImage drawInRect:CGRectMake(0, 0, 110, 300)]; [thirdImage drawInRect:CGRectMake(0, 0, 110, 300)]; //..... // [fourthImage drawInRect:CGRectMake(0,0,fourthImage.size.width ,fourthImage.size.height )]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    • 我猜 UIImage 没有 transform 属性.. 请再检查一下
    • 请将其设为 UIimageview 并将图像保留到 imageview 并分配转换功能
    猜你喜欢
    • 1970-01-01
    • 2021-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多