How to get a rotated, zoomed and panned image from an UIImageView at its full resolution?

前端 未结 3 1942
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 23:28

I have an UIImageView which can be rotated, panned and scaled with gesture recognisers. As a result it is cropped in its enclosing view. Everything is worki

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 00:00

    I think Bellow Code Capture Your Current View ...

    - (UIImage *)captureView {
    
        CGRect rect = [self.view bounds];
    
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        [self.yourImage.layer renderInContext:context];   
        UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        return img;
    
    }
    

    I think you want to save the display screen and use it ,so i post this code... Hope,this help you... :)

提交回复
热议问题