WYS
WYS

Reputation: 1647

Stick UIButton into an UIImageView's UIImage

I have an UIImageView with an UIButton that that I want to be able to send as an image with email, but the UIButton in the UIImageView wont be "stickied" with the UIImageView's image when I take the image out from the UIImageView.

Any suggestions?

Thanks in advance.

Upvotes: 0

Views: 99

Answers (1)

Shaheen M Basheer
Shaheen M Basheer

Reputation: 1010

You can add UIButton and UIImageView and get the required screenshot image using the following code. You might need to add the QuartzCore.framework to your project and #import

To get the image with other UI elements.

UIGraphicsBeginImageContext(CGSizeMake(320, 480)); // Here provide width and height of UIImageView
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];//Here use required view 
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();//outputImage is your required image
UIGraphicsEndImageContext();

To display the image

UIImageView * screenShotView = [[UIImageView alloc] initWithImage:outputImage];
[screenShotView setFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:screenShotView];

Upvotes: 1

Related Questions