1 前言
使用 cgaffinetransformmakescale/cgcontextscalectm 函数创建一个仿射缩放变换。
2 代码实例
zyviewcontrollerview.m
[plain]
- (void)drawrect:(cgrect)rect{
cgmutablepathref path = cgpathcreatemutable();
cgrect rectangle = cgrectmake(10.0f, 10.0f, 200.0f,
300.0f);
//将矩形缩放0.5
cgaffinetransform transform = cgaffinetransformmakescale(0.5f, 0.5f);
/* 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);
}
如对本文有疑问, 点击进行留言回复!!
POJ 3281 Dining (网络流/最大流建图拆点 EK+dinic解法)
IOS UIViewController和UIView的实用汇总
解决H5页面在iOS系统中滑动回弹效果(橡皮筋效果)导致的穿透问题
webpack-dev-server删除dist目录,图片不显示
Codeforces486 D. Valid Sets(树形dp,去重技巧)
网友评论