0

I am using UIActivityViewController for email, facebook, twitter and sms sharing..

I have successfully shared image as well text.

But, now i want to share UIView. I wanted to know is it possible or not?

If yes please let me know how.

Thanks in advance.

iGatiTech
  • 2,240
  • 1
  • 19
  • 43

2 Answers2

0

You can have a UIImage from a UIView,

Here is what you should be using if you are only supporting iOS7+:

+ (UIImage *) imageWithView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0f);
    [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
    UIImage * snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return snapshotImage;
}

Otherwise use this:

#import <QuartzCore/QuartzCore.h>

+ (UIImage *) imageWithView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;
}
Mutawe
  • 6,449
  • 3
  • 45
  • 89
0

You can take a screenshot of a UIView object. See please following topic:

How to capture UIView to UIImage without loss of quality on retina display

I have successfully shared image as well text.

After getting UIImage from UIView, you can share appropriate image.

Community
  • 1
  • 1
Alex Peda
  • 4,040
  • 3
  • 21
  • 30