【问题标题】:How can I rotate UIImage on clicking rotate button如何在单击旋转按钮时旋转 UIImage
【发布时间】:2023-03-28 14:11:01
【问题描述】:

我想在单击旋转按钮而不是方向更改时旋转 UIImage 而不是 UIImageView。请回复。

【问题讨论】:

    标签: iphone objective-c uiimage rotation


    【解决方案1】:
    CGSize size =  sizeOfImage;
    UIGraphicsBeginImageContext(size);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextRotateCTM(ctx, angleInRadians);
    CGContextDrawImage(UIGraphicsGetCurrentContext(),
      CGRectMake(0,0,size.width, size.height),
      image);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
    

    【讨论】:

    【解决方案2】:

    您可以使用imageWithCGImage:scale:orientation:(从 4.0 开始提供)

    【讨论】:

      【解决方案3】:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 1970-01-01
      相关资源
      最近更新 更多