CoreGraphics绘图: CGContextSetFillColor特定颜色无效问题
来源:互联网 发布:ubuntu 17.04 iso下载 编辑:程序博客网 时间:2024/06/06 00:31
Normally, most CGContexts are in an RGB color space. whiteColor
, on the other hand, is almost certainly in a white color space, which has only one or two (white and alpha) components.
So, since the context is in an RGB color space, CGContextSetFillColor
expects to be passed three or four (red, green, blue, and alpha) components. When you get the components of whiteColor
's CGColor, you get a pointer to a C array holding only two components. CGContextSetFillColor
will read the three or four components it wants no matter what; if you pass fewer, it may find garbage after them, or it may find zeroes.
If it finds a zero in the alpha position, then the result is that you have set the fill color to something between yellow (red=1.0, green=1.0, blue=0.0) and white (all three=1.0) with zero alpha. That's what causes the fill to not show up: You are filling with a transparent color.
The problem is that mismatch between the color space the context is in (with three or four components) and the color space the color is in (with one or two components). The solution is to remove the mismatch, which is what CGContextSetFillColorWithColor
does: Since you are passing the whole CGColor object, not just an array of numbers, Core Graphics will be able to set the context's color space to that of the color object and interpret the color object's components correctly.
- CoreGraphics绘图: CGContextSetFillColor特定颜色无效问题
- coreGraphics绘图
- 关于CoreGraphics绘图
- CoreGraphics简单绘图
- 【iOS】CoreGraphics简单绘图
- CoreGraphics简单绘图
- CoreGraphics简单绘图
- CoreGraphics简单绘图学习
- IOS开发:CoreGraphics简单绘图
- iOS绘图框架CoreGraphics分析
- iOS绘图框架CoreGraphics分析
- iOS绘图框架CoreGraphics分析
- CoreGraphics 2D绘图学习笔记
- iOS学习6:CoreGraphics简单绘图
- CoreGraphics之CGContext绘图 - iOS开发
- iOS学习6:CoreGraphics简单绘图
- iOS学习——CoreGraphics简单绘图
- iOS中 CoreGraphics快速绘图(详解)
- Shell中符号意义
- oradebug
- ioctl函数(下)
- 面向对象的三大特征
- MongoDB研究和实践
- CoreGraphics绘图: CGContextSetFillColor特定颜色无效问题
- 禁用cookie
- 使用Dom4j操作XML
- USACO Healthy Holsteins
- 在Drupal 7中添加区块时,不能使用PHP代码的原因与解决办法
- 用servlet实现文件下载
- netstat,nmap命令总结(鸟哥的LINUX私房菜)
- Oracle oradebug 命令 使用说明
- Hessian学习与示例