snapshotViewAfterScreenUpdates glitch on iOS 8

后端 未结 3 1989
Happy的楠姐
Happy的楠姐 2021-02-01 19:13

I\'ve noticed running this would cause view (or main window, not sure) to resize for a moment, when running on iPhone 6/6+ simulator scaled from iPhone 5 layout (without passing

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 19:40

    Since it seemed like an Apple/API problem, I just decided to not use that method when I need to pass a "YES."

    You can just take a screenshot (UIImage) of your view and place it in a UIImageView to act as the "UIView" you used to get from the snapshot method.

    Here's a link for code: How to capture UIView to UIImage without loss of quality on retina display

    #import 
    
    + (UIImage *) imageWithView:(UIView *)view
    {
        UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
        [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    
        UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
    
        UIGraphicsEndImageContext();
    
        return img;
    }
    

提交回复
热议问题