我有一个400x320的视图(testView),我需要截取这个视图的部分截图(比如rect =(50,50,200,200)).我正在玩iOS 7中的drawViewHierarchy方法,但我无法弄清楚如何正确地完成它.
UIGraphicsBeginImageContextWithOptions(self.testView.bounds.size, NO, [UIScreen mainScreen].scale); [self.testView drawViewHierarchyInRect:self.testView.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
任何帮助将不胜感激!
谢谢.