检测 UIColor 是否是用 colorWithPatternImage 创建的 [英] Detecting if UIColor was created with colorWithPatternImage
本文介绍了检测 UIColor 是否是用 colorWithPatternImage 创建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个传递给我的 UIColor
.我需要检测它是纯色(例如用 colorWithRed:green:blue:alpha:
创建)还是用 colorWithPatternImage
创建的颜色.
I have a UIColor
that is passed into me. I need to detect if it is a plain color (e.g. created with colorWithRed:green:blue:alpha:
) or if it is a color that was created with colorWithPatternImage
.
如何判断 UIColor
是什么颜色,简单的颜色还是其他颜色?
How can I tell what kind of color a UIColor
is, simple color or otherwise?
推荐答案
您应该能够使用带有 CGColor 属性的 CGColorGetPattern 函数,并检查 >NULL.
You should be able to use the CGColorGetPattern function with the CGColor property, and check for NULL.
if( CGColorGetPattern( myColor.CGColor ) != NULL ) {}
这篇关于检测 UIColor 是否是用 colorWithPatternImage 创建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文