iOS截图

来源:互联网 发布:广州盛高软件 编辑:程序博客网 时间:2024/05/22 10:40

//截图

        UIGraphicsBeginImageContext(self.view.frame.size);

        

        //1.取得绘图的画布

        CGContextRef context =UIGraphicsGetCurrentContext();

        CGContextSaveGState(context);

        

        //2.设置裁剪区域

       UIRectClip(imgView.frame);

        

        //3.imgView视图的裁剪区域部分,渲染到画布上

        [imgView.layerrenderInContext:context];

        

        //4.取得画布上的内容,转成UIImage对象

        UIImage *theImg =UIGraphicsGetImageFromCurrentImageContext();

        

       //5.结束绘图

        UIGraphicsEndImageContext();


0 0