- (void)drawRect:(CGRect)rect {
// Drawing code.
stickerImage = [UIImage imageNamed:@"betaImage.png"];
CGSize size = stickerImage.size;
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM( context, 0.5f * size.width, 0.5f * size.height );
CGContextRotateCTM (context, 90 * M_PI/180);
[stickerImage drawInRect:(CGRect){ { -size.width * 0.5f, -size.height * 0.5f }, size }];
UIGraphicsEndImageContext();
}
I just cannot find whats wrong with my code, it does not showing anything
Yep, you shouldn’t end your context before you get the result image. In your code example you should get the result image:
or just pass ending context to other parent methods;
As Morgan Harris said, all image manipulations should be between UIGraphicsBeginImageContext() and UIGraphicsEndImageContext();