CGContextSaveGState与CGContextRestoreGState的作用
来源:互联网 发布:linux进入新建用户 编辑:程序博客网 时间:2024/04/29 15:57
使用Quartz时涉及到一个图形上下文,其中图形上下文中包含一个图形状态堆栈。在Quartz创建图形上下文时,该堆栈是空的。CGContextSaveGState
函数的作用是将当前图形状态推入堆栈。之后,您对图形状态所做的修改会影响随后的描画操作,但不影响存储在堆栈中的拷贝。在修改完成后,您可以通过CGContextRestoreGState
函数把堆栈顶部的状态弹出,返回到之前的图形状态。这种推入和弹出的方式是回到之前图形状态的快速方法,避免逐个撤消所有的状态修改;这也是将某些状态(比如裁剪路径)恢复到原有设置的唯一方式。
UIGraphicsBeginImageContextWithOptions(targetRect.size, YES, 0.0); CGContextRef context = UIGraphicsGetCurrentContext(); float myFillColor[] = {1,0,0,1}; //red; CGContextSaveGState(context); CGContextSetRGBFillColor(context, 0,1,1,1); CGContextFillRect(context, targetRect); CGContextSetFillColor(context, myFillColor); CGContextFillEllipseInRect(context, targetRect); CGContextFillPath(context); CGContextRestoreGState(context); UIImage *uiImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
0 0
- CGContextSaveGState与CGContextRestoreGState的作用
- CGContextSaveGState与CGContextRestoreGState的作用
- CGContextSaveGState与CGContextRestoreGState的作用
- CGContextSaveGState与CGContextRestoreGState的作用
- iOS CGContextSaveGState与CGContextRestoreGState的作用
- CGContextSaveGState与CGContextRestoreGState的作用 (转)
- CGContextSaveGState与CGContextRestoreGState的功用
- CGContextSaveGState与CGContextRestoreGState详解
- 图形上下文保存与恢复(CGContextSaveGState与CGContextRestoreGState的)
- CGContextRestoreGState() 的作用
- 图形上下文解释CGContextSaveGState/CGContextRestoreGState
- CGContextSaveGState和CGContextRestoreGState UIGraphicsPushContext和UIGraphicsPopCo
- CGContextSaveGState与UIGraphicsPushContext的区别
- CGContextSaveGState与UIGraphicsPushContext的区别
- 【iOS开发-80】Quartz2D绘图简介:直线/圆形/椭圆/方形以及上下文栈管理CGContextSaveGState/CGContextRestoreGState
- Quartz2D绘图简介:直线/圆形/椭圆/方形以及上下文栈管理CGContextSaveGState/CGContextRestoreGState
- CoreGraphics之CGContextSaveGState与UIGraphicsPushContext
- iOS: CGContext的函数CGContextSaveGState
- java swing给按钮添加快捷键
- Xcode7 免证书 测试... (大坑...)
- 1023
- 学习-记录-分享
- 三局两胜还是五局三胜?
- CGContextSaveGState与CGContextRestoreGState的作用
- 我珍藏的一些安卓相关的网站
- boost::filesystem指南
- [Cryptography] Symmetric & Asymmetric
- ajax实现文件上传
- 74. PHP 计数器
- 有的时候我们需要用一个颜色值生成一张按钮的背景色,下面的方法就很有用了
- Beego 连接 MongoDB主从
- 使用windows Phone 集成横幅广告教程