天天看点

UIGraphicsBeginImageContext的应用

  • 开启一个基于位图的图形上下文
/*
 size :大小
 opaque : YES:不透明  NO:透明
 scale: 缩放比例
 */
void UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale)
           
  • 从上下文中取得图片(UIImage)
UIImage* UIGraphicsGetImageFromCurrentImageContext();
           
  • 结束基于位图的图形上下文
void    UIGraphicsEndImageContext();
           
  • 图片裁剪
void CGContextClip(CGContextRef c)

将当前上下所绘制的路径裁剪出来(超出这个裁剪区域的都不能显示)
           

继续阅读