我已经完成了没有导航栏的完整屏幕截图的编码,但我也不想要“激励我”按钮。
另外,如果有人知道如何将裁剪屏幕截图分享到 Facebook?
截图代码如下:
UIGraphicsBeginImageContextWithOptions(UIScreen.mainScreen().bounds.size,false,0);
self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
var image:UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
最佳答案
确保“激励我”按钮不在您正在截屏的 View 的层次结构中。将它移到一个单独的 View 上,然后使用您已有的相同代码。这将完全满足您的需求。
或者,如果您想裁剪整张照片,可以使用以下方法,请替换 heightOfButton 中的值以适合:
var heightOfButton: CGFloat = 100
var size = UIScreen.mainScreen().bounds.size
size.height -= heightOfButton
UIGraphicsBeginImageContextWithOptions(size,false,0);
self.view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
var image:UIImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
关于ios - 裁剪屏幕截图并分享?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32228335/