IOS开发(85)之缩放图像
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);
}
上一篇: JSP 自动刷新的实例详解
下一篇: 卵巢囊肿的原因和解决方法
推荐阅读
-
IOS开发(38)之Objective-c的@property 详解
-
IOS开发(36)之iOS 编码规范
-
IOS开发(37)之iphone开发中的delegate
-
IOS开发(46)之设置 NSZombieEnabled 定位 EXC_BAD_ACCESS 错误
-
IOS开发(41)之关于NSString和NSMutableString的retainCount
-
IOS开发(43)之10个迷惑新手的Cocoa&Objective-c开发问题
-
IOS开发(40)之objective-C 的内存管理之-引用计数
-
IOS开发(42)之IOS设计UI工具大全
-
IOS开发(39)之KVC KVO KVB
-
IOS开发(47)之iOS Block学习