Core Plot (iOS and tvOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTColor Class Reference

An immutable color. More...

#import <CPTColor.h>

+ Inheritance diagram for CPTColor:
+ Collaboration diagram for CPTColor:

Public Class Methods

Standard Colors
(nonnull instancetype) + clearColor
 Returns a shared instance of CPTColor initialized with a fully transparent color. More...
 
(nonnull instancetype) + whiteColor
 Returns a shared instance of CPTColor initialized with a fully opaque white color. More...
 
(nonnull instancetype) + lightGrayColor
 Returns a shared instance of CPTColor initialized with a fully opaque 67% gray color. More...
 
(nonnull instancetype) + grayColor
 Returns a shared instance of CPTColor initialized with a fully opaque 50% gray color. More...
 
(nonnull instancetype) + darkGrayColor
 Returns a shared instance of CPTColor initialized with a fully opaque 33% gray color. More...
 
(nonnull instancetype) + blackColor
 Returns a shared instance of CPTColor initialized with a fully opaque black color. More...
 
(nonnull instancetype) + redColor
 Returns a shared instance of CPTColor initialized with a fully opaque red color. More...
 
(nonnull instancetype) + greenColor
 Returns a shared instance of CPTColor initialized with a fully opaque green color. More...
 
(nonnull instancetype) + blueColor
 Returns a shared instance of CPTColor initialized with a fully opaque blue color. More...
 
(nonnull instancetype) + cyanColor
 Returns a shared instance of CPTColor initialized with a fully opaque cyan color. More...
 
(nonnull instancetype) + yellowColor
 Returns a shared instance of CPTColor initialized with a fully opaque yellow color. More...
 
(nonnull instancetype) + magentaColor
 Returns a shared instance of CPTColor initialized with a fully opaque magenta color. More...
 
(nonnull instancetype) + orangeColor
 Returns a shared instance of CPTColor initialized with a fully opaque orange color. More...
 
(nonnull instancetype) + purpleColor
 Returns a shared instance of CPTColor initialized with a fully opaque purple color. More...
 
(nonnull instancetype) + brownColor
 Returns a shared instance of CPTColor initialized with a fully opaque brown color. More...
 
Factory Methods
(nonnull instancetype) + colorWithCGColor:
 Creates and returns a new CPTColor instance initialized with the provided CGColorRef. More...
 
(nonnull instancetype) + colorWithComponentRed:green:blue:alpha:
 Creates and returns a new CPTColor instance initialized with the provided RGBA color components. More...
 
(nonnull instancetype) + colorWithGenericGray:
 Creates and returns a new CPTColor instance initialized with the provided gray level. More...
 
(nonnull instancetype) + colorWithUIColor:
 Creates and returns a new CPTColor instance initialized with the provided UIColor. More...
 
(nonnull instancetype) + colorWithNativeColor:
 Creates and returns a new CPTColor instance initialized with the provided platform-native color. More...
 
- Public Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Public Class Methods inherited from <NSSecureCoding>
(BOOL+ supportsSecureCoding:
 

Public Instance Methods

Initialization
(nonnull instancetype) - initWithCGColor:
 Initializes a newly allocated CPTColor object with the provided CGColorRef. More...
 
(nonnull instancetype) - initWithComponentRed:green:blue:alpha:
 Initializes a newly allocated CPTColor object with the provided RGBA color components. More...
 
(nullable instancetype) - initWithCoder:
 Returns an object initialized from data in a given unarchiver. More...
 
(nonnull instancetype) - initWithUIColor:
 Initializes a newly allocated CPTColor object with the provided UIColor. More...
 
(nonnull instancetype) - initWithNativeColor:
 Initializes a newly allocated CPTColor object with the provided platform-native color. More...
 
(nonnull instancetype) - colorWithAlphaComponent:
 Creates and returns a new CPTColor instance having color components identical to the current object but having the provided alpha component. More...
 
Comparison
(BOOL- isEqual: [implementation]
 Returns a boolean value that indicates whether the received is equal to the given object. Colors are equal if they have equal cgColor properties. More...
 
- Public Instance Methods inherited from NSObject
(Class- classForCoder
 
(id- copy
 
(void) - dealloc
 
(void) - finalize
 
(id- init
 
(id- mutableCopy
 
- Public Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Public Instance Methods inherited from <NSCopying>
(id- copyWithZone:
 
- Public Instance Methods inherited from <NSCoding>
(id- initWithCoder:
 
(void) - encodeWithCoder:
 

Properties

CGColorRef cgColor
 The CGColorRef to wrap around. More...
 
BOOL opaque
 If YES, the color is completely opaque. More...
 
UIColoruiColor
 The UIColor to wrap around. More...
 
CPTNativeColornativeColor
 The platform-native color to wrap around. More...
 

Detailed Description

An immutable color.

An immutable object wrapper class around CGColorRef. It provides convenience methods to create the same predefined colors defined by UIColor.

Method Documentation

◆ blackColor

+ (nonnull instancetype) blackColor

Returns a shared instance of CPTColor initialized with a fully opaque black color.

Returns
A shared CPTColor object initialized with a fully opaque black color.

◆ blueColor

+ (nonnull instancetype) blueColor

Returns a shared instance of CPTColor initialized with a fully opaque blue color.

Returns
A shared CPTColor object initialized with a fully opaque blue color.

◆ brownColor

+ (nonnull instancetype) brownColor

Returns a shared instance of CPTColor initialized with a fully opaque brown color.

Returns
A shared CPTColor object initialized with a fully opaque brown color.

◆ clearColor

+ (nonnull instancetype) clearColor

Returns a shared instance of CPTColor initialized with a fully transparent color.

Returns
A shared CPTColor object initialized with a fully transparent color.

◆ colorWithAlphaComponent:

- (nonnull instancetype) colorWithAlphaComponent: (CGFloat alpha

Creates and returns a new CPTColor instance having color components identical to the current object but having the provided alpha component.

Parameters
alphaThe alpha component (0alpha1).
Returns
A new CPTColor instance having the provided alpha component.

◆ colorWithCGColor:

+ (nonnull instancetype) colorWithCGColor: (nonnull CGColorRef newCGColor

Creates and returns a new CPTColor instance initialized with the provided CGColorRef.

Parameters
newCGColorThe color to wrap.
Returns
A new CPTColor instance initialized with the provided CGColorRef.

◆ colorWithComponentRed:green:blue:alpha:

+ (nonnull instancetype) colorWithComponentRed: (CGFloat red
green: (CGFloat green
blue: (CGFloat blue
alpha: (CGFloat alpha 

Creates and returns a new CPTColor instance initialized with the provided RGBA color components.

Parameters
redThe red component (0red1).
greenThe green component (0green1).
blueThe blue component (0blue1).
alphaThe alpha component (0alpha1).
Returns
A new CPTColor instance initialized with the provided RGBA color components.

◆ colorWithGenericGray:

+ (nonnull instancetype) colorWithGenericGray: (CGFloat gray

Creates and returns a new CPTColor instance initialized with the provided gray level.

Parameters
grayThe gray level (0gray1).
Returns
A new CPTColor instance initialized with the provided gray level.

◆ colorWithNativeColor:

+ (nonnull instancetype) colorWithNativeColor: (nonnull CPTNativeColor *)  newColor

Creates and returns a new CPTColor instance initialized with the provided platform-native color.

The color can be a dynamic system color or catalog color. This adds support for Dark Mode in iOS13.

Parameters
newColorThe color to wrap.
Returns
A new CPTColor instance initialized with the provided platform-native color.

◆ colorWithUIColor:

+ (nonnull instancetype) colorWithUIColor: (nonnull UIColor *)  newUIColor

Creates and returns a new CPTColor instance initialized with the provided UIColor.

The UIColor can be a dynamic system color or catalog color. This adds support for Dark Mode in iOS 13.

Parameters
newUIColorThe color to wrap.
Returns
A new CPTColor instance initialized with the provided UIColor.

◆ cyanColor

+ (nonnull instancetype) cyanColor

Returns a shared instance of CPTColor initialized with a fully opaque cyan color.

Returns
A shared CPTColor object initialized with a fully opaque cyan color.

◆ darkGrayColor

+ (nonnull instancetype) darkGrayColor

Returns a shared instance of CPTColor initialized with a fully opaque 33% gray color.

Returns
A shared CPTColor object initialized with a fully opaque 33% gray color.

◆ grayColor

+ (nonnull instancetype) grayColor

Returns a shared instance of CPTColor initialized with a fully opaque 50% gray color.

Returns
A shared CPTColor object initialized with a fully opaque 50% gray color.

◆ greenColor

+ (nonnull instancetype) greenColor

Returns a shared instance of CPTColor initialized with a fully opaque green color.

Returns
A shared CPTColor object initialized with a fully opaque green color.

◆ initWithCGColor:

- (nonnull instancetype) initWithCGColor: (nonnull CGColorRef newCGColor

Initializes a newly allocated CPTColor object with the provided CGColorRef.

Parameters
newCGColorThe color to wrap.
Returns
The initialized CPTColor object.

◆ initWithCoder:

- (nullable instancetype) initWithCoder: (nonnull NSCoder *)  coder

Returns an object initialized from data in a given unarchiver.

Parameters
coderAn unarchiver object.
Returns
An object initialized from data in a given unarchiver.

◆ initWithComponentRed:green:blue:alpha:

- (nonnull instancetype) initWithComponentRed: (CGFloat red
green: (CGFloat green
blue: (CGFloat blue
alpha: (CGFloat alpha 

Initializes a newly allocated CPTColor object with the provided RGBA color components.

Parameters
redThe red component (0red1).
greenThe green component (0green1).
blueThe blue component (0blue1).
alphaThe alpha component (0alpha1).
Returns
The initialized CPTColor object.

◆ initWithNativeColor:

- (nonnull instancetype) initWithNativeColor: (nonnull CPTNativeColor *)  newColor

Initializes a newly allocated CPTColor object with the provided platform-native color.

The color can be a dynamic system color or catalog color. This adds support for Dark Mode in macOS 10.14 and iOS 13.

Parameters
newColorThe color to wrap.
Returns
The initialized CPTColor object.

◆ initWithUIColor:

- (nonnull instancetype) initWithUIColor: (nonnull UIColor *)  newUIColor

Initializes a newly allocated CPTColor object with the provided UIColor.

The UIColor can be a dynamic system color or catalog color. This adds support for Dark Mode in iOS 13.

Parameters
newUIColorThe color to wrap.
Returns
The initialized CPTColor object.

◆ isEqual:

- (BOOL) isEqual: (nullable id object
implementation

Returns a boolean value that indicates whether the received is equal to the given object. Colors are equal if they have equal cgColor properties.

Parameters
objectThe object to be compared with the receiver.
Returns
YES if object is equal to the receiver, NO otherwise.

◆ lightGrayColor

+ (nonnull instancetype) lightGrayColor

Returns a shared instance of CPTColor initialized with a fully opaque 67% gray color.

Returns
A shared CPTColor object initialized with a fully opaque 67% gray color.

◆ magentaColor

+ (nonnull instancetype) magentaColor

Returns a shared instance of CPTColor initialized with a fully opaque magenta color.

Returns
A shared CPTColor object initialized with a fully opaque magenta color.

◆ orangeColor

+ (nonnull instancetype) orangeColor

Returns a shared instance of CPTColor initialized with a fully opaque orange color.

Returns
A shared CPTColor object initialized with a fully opaque orange color.

◆ purpleColor

+ (nonnull instancetype) purpleColor

Returns a shared instance of CPTColor initialized with a fully opaque purple color.

Returns
A shared CPTColor object initialized with a fully opaque purple color.

◆ redColor

+ (nonnull instancetype) redColor

Returns a shared instance of CPTColor initialized with a fully opaque red color.

Returns
A shared CPTColor object initialized with a fully opaque red color.

◆ whiteColor

+ (nonnull instancetype) whiteColor

Returns a shared instance of CPTColor initialized with a fully opaque white color.

Returns
A shared CPTColor object initialized with a fully opaque white color.

◆ yellowColor

+ (nonnull instancetype) yellowColor

Returns a shared instance of CPTColor initialized with a fully opaque yellow color.

Returns
A shared CPTColor object initialized with a fully opaque yellow color.

Property Documentation

◆ cgColor

- (CGColorRef) cgColor
readnonatomicassign

The CGColorRef to wrap around.

◆ nativeColor

- (CPTNativeColor *) nativeColor
readnonatomicassign

The platform-native color to wrap around.

◆ opaque

- (BOOL) opaque
readnonatomicassign

If YES, the color is completely opaque.

◆ uiColor

- (UIColor *) uiColor
readnonatomicassign

The UIColor to wrap around.


The documentation for this class was generated from the following files: