I am trying to convert my UIView into UIImage using below code.
+ (UIImage *) imageWithView:(UIView *)view{
float scale = 1.0f;
UIGraphicsBeginImag
I just had this happen to me (memory leak due to renderInContext
) on the main thread. I was looping over hundreds off-screen views, rendering them to UIImage
objects, and saving them as PNG files. What solved the problem for me was wrapping the guts of my loop in an @autoreleasepool
block:
Broken:
for (...) {
...render layer in context...
...save image to disk...
}
Works:
for (...) {
@autoreleasepool {
...render layer in context...
...save image to disk...
}
}
Makes sense, right?