Permalink
Browse files

add lighterColor and darkerColor helpers

  • Loading branch information...
1 parent 33a412c commit 8f1e0979f0bc69b04e78d4135ee48e1a3d62eda3 @ettore committed Nov 8, 2013
Showing with 58 additions and 0 deletions.
  1. +16 −0 categories/UIColor+CLCG.h
  2. +42 −0 categories/UIColor+CLCG.m
View
@@ -0,0 +1,16 @@
+//
+// UIColor+CLCG.h
+// Candygirl
+// Created by Pasquini, Ettore on 11/7/13.
+//
+
+
+@interface UIColor (CLCG)
+
+/** @return A color that's 25% brighter than self. */
+- (UIColor *)lighterColor;
+
+/** @return A color that's 25% darker than self. */
+- (UIColor *)darkerColor;
+
+@end
View
@@ -0,0 +1,42 @@
+//
+// UIColor+CLCG.m
+// Candygirl
+// Created by Pasquini, Ettore on 11/7/13.
+//
+
+#import "UIColor+CLCG.h"
+
+
+@implementation UIColor (CLCG)
+
+
+- (UIColor *)lighterColor
+{
+ CGFloat h, s, b, a;
+
+ if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) {
+ return [UIColor colorWithHue:h
+ saturation:s
+ brightness:MIN(b * 1.3, 1.0)
+ alpha:a];
+ }
+
+ return nil;
+}
+
+
+- (UIColor *)darkerColor
+{
+ CGFloat h, s, b, a;
+
+ if ([self getHue:&h saturation:&s brightness:&b alpha:&a]) {
+ return [UIColor colorWithHue:h
+ saturation:s
+ brightness:b * 0.75
+ alpha:a];
+ }
+
+ return nil;
+}
+
+@end

0 comments on commit 8f1e097

Please sign in to comment.