Archive for category MFMailComposer

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 Code

Output :-

This slideshow requires JavaScript.


Leave a comment