几种把View转化为Image的方法

2017-03-23  本文已影响59人  七维树

首先开启上下文

if(UIGraphicsBeginImageContextWithOptions != NULL)
{
        UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0);
} else {
        UIGraphicsBeginImageContext(view.frame.size);
}

然后

[view snapshotViewAfterScreenUpdates:YES]

绘制的方法
方法一 不支持Retina屏幕

[view.layer renderInContext:UIGraphicsGetCurrentContext()];

方法二

[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];

方法三

[view drawLayer:view.layer inContext:UIGraphicsGetCurrentContext()];
上一篇 下一篇

猜你喜欢

热点阅读