//开启位图上下文,将图片渲染到位图上下文
UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[self.layer renderInContext:ctx];
UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();