把当前页面绘制为图片

 法1:

  UIGraphicsBeginImageContextWithOptions((view.bounds.size), NO , 0);//绘制出来的不模糊

 //   UIGraphicsBeginImageContext()//这种的绘制会模糊

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    [view.layer renderInContext:ctx];

    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

法2:

 UIGraphicsBeginImageContextWithOptions((view.bounds.size), NO , 0);

 [view drawRect:CGRectMake(0, 0, view.frameWidth, view.frameHeight)];

 UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

 UIGraphicsEndImageContext();

posted @ 2018-03-07 11:56  菜鸟好笨笨!  阅读(161)  评论(0编辑  收藏  举报