background image

   

    

//结束绘画

    

UIImage

 *destImg = 

UIGraphicsGetImageFromCurrentImageContext

();

    

UIGraphicsEndImageContext

();

   

    

//创建 UIImageView 并显示在界面上

    

UIImageView

 *imgView = [[

UIImageView

 

alloc

initWithImage

:destImg];

    [

self

.

view

 

addSubview

:imgView];

}

 

图片就显示出来了:

 

接下来绘制

Clip 区域。使

Quartz 中的 Path 创建

操作去绘制一个菱形边框,
最后使用

CGContextClip

函数把当前

Path 作为

Clip 区域。

把下面代码插入到上方
“开始绘制图片”和“坐标
系转化

”之间。因为如果在

画完图后在设置

Clip 区

域那就没有任何意义了。

//绘制 Clip 区域

CGContextMoveToPoint

(gc, width/

2

0

);