IOS开发(84)之移动图形
1 前言
使用 cgaffinetransformmaketranslation 函数创建一个仿射位移变换(affine translation transformation)。将被绘制到图形环境上的一切,到一个新的位置,而不需要修改你的绘图代码。
2 代码实例
zyviewcontrollerview.m
[plain] - (void)drawrect:(cgrect)rect{
cgmutablepathref path = cgpathcreatemutable();
cgrect rectangle = cgrectmake(10.0f, 10.0f, 200.0f,
300.0f);
//将矩形向右移动100而纵向不变
cgaffinetransform transform = cgaffinetransformmaketranslation(100.0f, 0.0f);
/* add the rectangle to the path */
cgpathaddrect(path,&transform, rectangle);
/* get the handle to the current context */
cgcontextref currentcontext = uigraphicsgetcurrentcontext();
/* add the path to the context */
cgcontextaddpath(currentcontext,path);
/* set the fill color to cornflower blue */
[[uicolor colorwithred:0.20f green:0.60f blue:0.80f alpha:1.0f] setfill];
/* set the stroke color to brown */
[[uicolor browncolor] setstroke];
/* set the line width (for the stroke) to 5 */
cgcontextsetlinewidth(currentcontext,5.0f);
/* stroke and fill the path on the context */
cgcontextdrawpath(currentcontext,kcgpathfillstroke);
/* dispose of the path */
cgpathrelease(path);
}
上一篇: 男人如何壮阳才能够变得更加强壮?
下一篇: java关闭流连接IO工具类