2012-04-22 89 views
0

我有一个UIImageView与UIButton,我希望能够作为图像发送电子邮件,但UIImageView中的UIButton不会与UIImageView的图像“粘贴”,当我拿从UIImageView中映射出来。粘UIButton到UIImageView的UIImage

有什么建议吗?

在此先感谢。

+0

你是什么意思 “stickied” 是什么意思? – 2012-04-22 11:48:26

+0

我的意思是...我有一个UIImageView,我添加一个UIButton作为UIImageView的子视图。当我尝试使用UIImageView.image时,我没有得到我作为UIImageView的子视图添加的按钮。 – WYS 2012-04-22 13:22:04

+0

哦,谢谢RIP,我会为我所有的问题做到这一点:) – WYS 2012-04-22 13:23:44

回答

1

您可以使用以下代码添加UIButton和UIImageView并获取所需的屏幕截图。 您可能需要将QuartzCore.framework添加到您的项目和#import

要获取具有其他UI元素的图像。

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(); 

显示图像

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

非常感谢,正是我所需要的! :) – WYS 2012-04-22 18:45:40