SKColor(TKRendererCompatibility) Category Reference

Declared in TKRendererCompatibility.h

Overview

SKColor category

Color for String

+ colorWithString:

Creates a color from a hex-encoded color string (as in HTML) in the format ‘#rrggbb’ or ‘rrggbb’. The leading # is optional.

+ (nullable SKColor *)colorWithString:(nonnull NSString *)string

Parameters

string

A string with a color encoding.

Return Value

The color that was converted from string, or nil if the string could not be decoded.

Discussion

Valid color string examples:

  • #ff0000 (red color)
  • 20ff20 (green color with a hint of red and blue)

Declared In

TKRendererCompatibility.h

Random Color

+ randomColor

Creates a randomized color.

+ (nonnull SKColor *)randomColor

Return Value

A randomized color with alpha 1.0.

Declared In

TKRendererCompatibility.h

+ randomColorWithAlpha:

Creates a randomized color with a given alpha value.

+ (nonnull SKColor *)randomColorWithAlpha:(CGFloat)alpha

Parameters

alpha

The color’s alpha value.

Return Value

A randomized color.

Declared In

TKRendererCompatibility.h