在作微博分享的時候須要當前頁面的截圖,搜了下代碼,很是簡單,以下:
UIGraphicsBeginImageContext(self.view.frame.size); //currentView 當前的view
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
viewImage就是獲取的截圖,若是要將圖片存入相冊,只需在後面調用
UIImageWriteToSavedPhotosAlbum(viewImage,nil,nil,nil);spa