Skip to content

Commit

Permalink
Use UIColor+Hex instead of a custom macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Apr 23, 2014
1 parent 98a2135 commit 20b0c77
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
3 changes: 1 addition & 2 deletions Demo/EDColoriOS7ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectio
return 0;
}

- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(0, 0, 0, 0);
}
Expand Down
33 changes: 14 additions & 19 deletions EDColor/UIColor+iOS7.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@
//

#import "UIColor+iOS7.h"
#import "UIColor+Hex.h"

@implementation UIColor (iOS7)

#define colorFromInteger(Color) [UIColor \
colorWithRed:((Color & 0xFF0000) >> 16) / 255.0 \
green:((Color & 0xFF00) >> 8) / 255.0 \
blue:(Color & 0xFF) / 255.0 \
alpha:1]

#define gradientPair(name, start, end) \
+ (instancetype)iOS7##name##GradientStartColor { return colorFromInteger(start); } \
+ (instancetype)iOS7##name##GradientEndColor { return colorFromInteger(end); } \
+ (instancetype)iOS7##name##GradientStartColor { return [UIColor colorWithHex:start]; } \
+ (instancetype)iOS7##name##GradientEndColor { return [UIColor colorWithHex:end]; } \
+ (NSArray *)iOS7##name##Gradient { return @[(id)UIColor.iOS7##name##GradientStartColor, (id)UIColor.iOS7##name##GradientEndColor]; }

+ (NSArray *)iOS7GradientPairs
Expand Down Expand Up @@ -55,17 +50,17 @@ + (NSArray *)iOS7Colors
];
}

+ (instancetype)iOS7redColor { return colorFromInteger(0xFF3B30); }
+ (instancetype)iOS7orangeColor { return colorFromInteger(0xFF9500); }
+ (instancetype)iOS7yellowColor { return colorFromInteger(0xFFCC00); }
+ (instancetype)iOS7greenColor { return colorFromInteger(0x4CD964); }
+ (instancetype)iOS7tealColor { return colorFromInteger(0x34AADC); }
+ (instancetype)iOS7blueColor { return colorFromInteger(0x007AFF); }
+ (instancetype)iOS7violetColor { return colorFromInteger(0x5856D6); }
+ (instancetype)iOS7magentaColor { return colorFromInteger(0xFF2D55); }
+ (instancetype)iOS7darkGreyColor { return colorFromInteger(0x8E8E93); }
+ (instancetype)iOS7lightGreyColor { return colorFromInteger(0xC7C7CC); }
+ (instancetype)iOS7charcoalColor { return colorFromInteger(0x4A4A4A); }
+ (instancetype)iOS7redColor { return [UIColor colorWithHex:0xFF3B30]; }
+ (instancetype)iOS7orangeColor { return [UIColor colorWithHex:0xFF9500]; }
+ (instancetype)iOS7yellowColor { return [UIColor colorWithHex:0xFFCC00]; }
+ (instancetype)iOS7greenColor { return [UIColor colorWithHex:0x4CD964]; }
+ (instancetype)iOS7tealColor { return [UIColor colorWithHex:0x34AADC]; }
+ (instancetype)iOS7blueColor { return [UIColor colorWithHex:0x007AFF]; }
+ (instancetype)iOS7violetColor { return [UIColor colorWithHex:0x5856D6]; }
+ (instancetype)iOS7magentaColor { return [UIColor colorWithHex:0xFF2D55]; }
+ (instancetype)iOS7darkGreyColor { return [UIColor colorWithHex:0x8E8E93]; }
+ (instancetype)iOS7lightGreyColor { return [UIColor colorWithHex:0xC7C7CC]; }
+ (instancetype)iOS7charcoalColor { return [UIColor colorWithHex:0x4A4A4A]; }

gradientPair(red, 0xFF5E3A, 0xFF2A68)
gradientPair(orange, 0xFF9500, 0xFF5E3A)
Expand Down

0 comments on commit 20b0c77

Please sign in to comment.