Take Screen-shot of Current View and Attach it to Mail

Hello Everyone,

This is my first tutorial for iOS Developers. I am starting with the very basic application cum functionality which is “How to take screen-shot of the current view and attaching it to the mail?”.

I have made a separate class named “CommonAPI” which will be very easy to use in your projects.

In this CommonAPI class I have written the methods which will get the screenshots and simply give the image to you. Then you can do whatever you want.


#import <Foundation/Foundation.h>

@interface CommanAPI : NSObject {


//+ (UIViewController*)viewController:(UIView*)iView;

+ (UIImage*)makeScreenShot:(UIView*)iView;




#import "CommanAPI.h"

#import <QuartzCore/QuartzCore.h>

@implementation CommanAPI

+ (UIViewController*)viewController:(UIView*)iView{

for (UIView* next = [iView superview]; next; next = next.superview) {

UIResponder* nextResponder = [next nextResponder];

if ([nextResponder isKindOfClass:[UIViewController class]]) {

return (UIViewController*)nextResponder;



return nil;




[iView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *tmpImage = UIGraphicsGetImageFromCurrentImageContext();


return tmpImage;



return (M_PI * (x) / 180.0);



Download Source Codehttps://github.com/akshaythakur/AttachScreenShotinMail/tree/code

Output :-

This slideshow requires JavaScript.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: