不用 2d截圖 直接截圖spa
1 -(UIImage *)screenShots 2 { 3 //截取整個backview 4 UIGraphicsBeginImageContext(self.backgroundView.bounds.size); 5 [self.backgroundView.layer renderInContext:UIGraphicsGetCurrentContext()]; 6 UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext(); 7 UIGraphicsEndImageContext(); 8 9 //在截圖上畫下本身須要的位置及大小 10 UIGraphicsBeginImageContext(self.mainContentView.frame.size); 11 [sourceImage drawAtPoint:CGPointMake(0, self.mainContentView.bounds.size.height - self.view.bounds.size.height)];13 UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); 14 UIGraphicsGetCurrentContext(); 15 16 return image; 17 }