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

前端 未结 4 1303
醉梦人生
醉梦人生 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 02:41

    The doc says

    Initializes a Core Image color object using an AppKit color object.

    So you need create CIColor from NSColor class

    CIColor *aCIColor = [[CIColor alloc] initWithColor:[NSColor blackColor]];
    

    The diff between UIColor and CIColor in that UIColor from UIKit framework and using in iOS. From Doc Available in iOS 2.0 and later

    A UIColor object represents color and sometimes opacity (alpha value). You can use UIColor objects to store color data, and during drawing you can use them to set the current fill and stroke colors

    CIColor from CoreImage framework and using in Mac OSX Available in OS X v10.4 and later

    The CIColor class contains color values and the color space for which the color values are valid. 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.

提交回复
热议问题