UIColor and CIColor how do they compare and what is the purpose of having two of them?

前端 未结 4 1217
醉梦人生
醉梦人生 2021-01-23 02:35

Recently I encountered some code where trying to get the CIColor property of a UIColor fails. The UIColor was initialized as a simple [UIColor blackColor] and trying to get the

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-23 03:01

    CIColor, like UIColor, is used to represent channel dimensions of a color.

    The difference as the documentation puts it is:

    You use CIColor objects in conjunction with other Core Image classes, such as CIFilter, CIContext,and CIImage, to take advantage of the built-in Core Image filters when processing images.

    From WWDC 2013:

    So, because, you know, and CIColor doesn't handle color spaces, it won't do CMYK color, it won't do patterns.

    So, these are all things that you're going to lose.

    If you ever think that you're going to need that, then probably not the right strategy.

    An alternate way, other than what has been already answered before me, You could have created the CIColor by creating CGColor of Black UIColor like:

    CIColor *color = [CIColor colorWithCGColor:[[UIColor blackColor] CGColor]];
    

提交回复
热议问题