Objective-C 截圖實現
作者:佚名
本文為大家呈現了一個Objective-C的截圖實現的方法,希望大家能夠加以利用。
截取整個屏幕大小:
- UIGraphicsBeginImageContext(self.view.bounds.size);
- [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
- UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil)
截取自定義大小:
- UIGraphicsBeginImageContext(_attributedLabel.frame.size);
- [_attributedLabel.layer renderInContext:UIGraphicsGetCurrentContext()];
- UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
項目需要導入QuartzCore.framework
責任編輯:閆佳明
來源:
oschina