Frage

I would like to automatically add a image frame to a taken screenshot. Here´s the code I´m using to take the screenshot. Any Ideas to put this image around the taken screenshot?

For the completeness: I want to give the user a option to share this beautiful screenshot with it´s frame on Twitter or Facebook.

BTW: That´s my first app as programmer, so please give me full solution or a tutorial to do this…

Screenshot: http://techstern.de/app/screenshot1.png
Frame I want to put around it: http://oi45.tinypic.com/2qvv2tv.jpg
Prototype: visit https://i.stack.imgur.com/hg1nW.png

Code

- (UIImage *)screenshot
{
    UIGraphicsBeginImageContext(self.view.frame.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

*I can´t put more than 2 links in this article because I´ve just signed up.

War es hilfreich?

Lösung

The solution I proposed in the comments.

- (UIImage *)screenShot {
    UIImage *frame = [UIImage imageNamed:@"frame"];

    UIGraphicsBeginImageContext(frame.size);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    [frame drawAtPoint:CGPointZero blendMode:kCGBlendModeOverlay alpha:1.0];

    CGContextTranslateCTM(ctx, xCordinateOfScreenshotInFrame, yCordinateOfScreenshotInFrame);
    [self.view.layer renderInContext:ctx];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top