hank
2017-06-14 3f9b5125cd79f60e878a3f93708d1254048fd1fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//
//  TWTRColorUtil.h
//
//  Created by Jacob Harding on 5/8/14.
//  Copyright (c) 2014 Twitter. All rights reserved.
//
 
#import <Foundation/Foundation.h>
#if IS_UIKIT_AVAILABLE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
 
// This adds type name compatibility, but definitely not API cmopatibility for these classes. This
// is really a temporarly workaround to get this code building for OS X.
typedef NSColor UIColor;
typedef NSImage UIImage;
#endif
 
NS_ASSUME_NONNULL_BEGIN
 
// Based off of rosetta color palette,
// see https://svn.twitter.biz/design/main/resources/colors/rosetta_colors.html (go/colors).
@interface TWTRColorUtil : NSObject
 
#pragma mark - Black and White
 
+ (UIColor *)blackColor;
+ (UIColor *)whiteColor;
 
#pragma mark - Blues
 
+ (UIColor *)blueColor;
+ (UIColor *)blueTextColor;
+ (UIColor *)lightBlueColor;
+ (UIColor *)mediumBlueColor;
+ (UIColor *)darkBlueColor;
 
#pragma mark - Reds
 
+ (UIColor *)redColor;
+ (UIColor *)darkRedColor;
 
#pragma mark - Purples
 
+ (UIColor *)darkPurpleColor;
+ (UIColor *)deepPurpleColor;
+ (UIColor *)mediumPurpleColor;
 
#pragma mark - Grays
 
+ (UIColor *)grayTextColor;
+ (UIColor *)darkGrayTextColor;
+ (UIColor *)grayColor;
+ (UIColor *)borderGrayColor;
+ (UIColor *)darkBorderGrayColor;
+ (UIColor *)faintGrayColor;
+ (UIColor *)mediumGrayColor;
+ (UIColor *)darkGrayColor;
 
#pragma mark - Component Colors
 
+ (UIColor *)textColor;
+ (UIColor *)imagePlaceholderColor;
 
#pragma mark - Utilities
 
+ (NSInteger)hexWithColor:(UIColor *)color;
+ (UIColor *)colorFromHex:(NSInteger)hex;
 
+ (UIImage *)imageWithColor:(UIColor *)color;
+ (BOOL)isLightColor:(UIColor *)color;
+ (BOOL)isLightColor:(UIColor *)color lightnessThreshold:(CGFloat)lightnessThreshold;
 
+ (BOOL)isOpaqueColor:(UIColor *)color;
 
#pragma mark - Color calculations
 
/**
 * Returns a secondary text color by
 * a) picking an alpha component based on whether the background color is light
 * b) applying that alpha component to the primary text color
 */
+ (UIColor *)secondaryTextColorFromPrimaryTextColor:(UIColor *)primaryTextColor backgroundColor:(UIColor *)backgroundColor;
 
/**
 * Returns a media background color by
 * a) picking an alpha component based on whether the background color is light
 * b) applying that alpha component to either solid white or black, based on the background
 */
+ (UIColor *)mediaBackgroundColorFromBackgroundColor:(UIColor *)backgroundColor;
 
/**
 * Returns a logo color appropriate for the background color.
 */
+ (UIColor *)logoColorFromBackgroundColor:(UIColor *)backgroundColor;
 
/**
 *  Returns a color for the text of a button given its background
 *  color. This is intended for use in buttons or to highlight text.
 *
 *  @param backgroundColor Background color where the text is displayed.
 *
 *  @return Color of the text.
 */
+ (UIColor *)contrastingTextColorFromBackgroundColor:(UIColor *)backgroundColor;
 
/**
 *  Returns a darker color based on the original color and a percent to darken.
 *
 *  @param color         The original color
 *  @param lightnessLevel   Lightness levels to lighten. Capped to 0 and 1.0.
 */
+ (UIColor *)darkerColorForColor:(UIColor *)color lightnessLevel:(CGFloat)lightnessLevel;
 
/**
 *  Returns a darker color based on the original color and a percent to lighten.
 *
 *  @param color            The original color
 *  @param lightnessLevel   Lightness levels to lighten. Capped to 0 and 1.0.
 */
+ (UIColor *)lighterColorForColor:(UIColor *)color lightnessLevel:(CGFloat)lightnessLevel;
 
@end
 
NS_ASSUME_NONNULL_END