// iphone 截屏方法
- (UIImage *)imageFromView:(UIView *)theView
{
UIGraphicsBeginImageContext(theView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[theView.layer renderInContext: context];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
当需要将当前界面转化为image时,调用上述方法
//如果需要分享回调,请将delegate对象设置self,并实现下面的回调方法
- (void)shareUM
{
[UMSocialData defaultData].extConfig.title = @"分享的title";
[UMSocialData defaultData].extConfig.qqData.url = @"http://baidu.com";
[UMSocialSnsService presentSnsIconSheetView:self
appKey:@"507fcab25270157b37000010"
shareText:@"友盟社会化分享让您快速实现分享等社会化功能,http://umeng.com/social"
shareImage:[self imageFromView:self.view];
shareToSnsNames:@[UMShareToWechatSession,UMShareToWechatTimeline,UMShareToSina,UMShareToQQ,UMShareToQzone]
delegate:self];
}
本文介绍了一种方法,用于将应用程序中的当前显示界面转换为图像,这一功能常用于分享当前屏幕内容。通过调用特定的方法,可以实现这一转化过程。
1万+

被折叠的 条评论
为什么被折叠?



