Automatically add Image frame to taken screenshot

陌路散爱 提交于 2019-12-13 04:39:26

问题


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 http://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.


回答1:


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;
}


来源:https://stackoverflow.com/questions/23630270/automatically-add-image-frame-to-taken-screenshot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!