简体   繁体   中英

iOS - weird UIView Offset

I use this function to create image from :

UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0f);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIImage * snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshotImage;

The code UIImage * snapshotImage = UIGraphicsGetImageFromCurrentImageContext(); make my screen have a glitch: 在此处输入图片说明

How can I resolve this issue? This only happen in . I do not have this issue in .

After much of trial and error, I found the course:

[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];

when afterScreenUpdates: set to YES , I will have that glitch. Once I set it to NO , the problem go away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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