Domanda

I have one UIImage which I want to deep copy to another (so that I may add it to an NSMUtableArray of images)

I cannot get it to deep copy, I have looked at zones and such but this no luck.

This is what I have trieD:

_incrementalImage = UIGraphicsGetImageFromCurrentImageContext();

UIImage *imgcpy = [[UIImage allocWithZone:[_incrementalImage zone]];
[stack addObject:imgcpy];

Basically I need a copy of incrementalImage onto stack that won't change if _incrementalImage or currentImageContext changes.

È stato utile?

Soluzione

UIImage *image1 = [UIImage imageNamed:@"someImage"];
UIImage *image2 = [UIImage imageWithCGImage:image1.CGImage];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top