diff --git a/Pod/Classes/Objective-C/UIColor+Chameleon.h b/Pod/Classes/Objective-C/UIColor+Chameleon.h index 5e206f4..0470ebf 100755 --- a/Pod/Classes/Objective-C/UIColor+Chameleon.h +++ b/Pod/Classes/Objective-C/UIColor+Chameleon.h @@ -57,7 +57,13 @@ typedef NS_ENUM (NSUInteger, UIGradientStyle) { * * @since 1.0 */ - UIGradientStyleTopToBottom + UIGradientStyleTopToBottom, + /** + * Returns a gradual blend between colours originating at the bottom-leftmost point and ending at the top-rightmost point of an object's frame. + * + * Custom + */ + UIGradientStyleDiagonal }; /** diff --git a/Pod/Classes/Objective-C/UIColor+Chameleon.m b/Pod/Classes/Objective-C/UIColor+Chameleon.m index 1955674..99e4ec7 100755 --- a/Pod/Classes/Objective-C/UIColor+Chameleon.m +++ b/Pod/Classes/Objective-C/UIColor+Chameleon.m @@ -539,6 +539,26 @@ + (UIColor *)colorWithGradientStyle:(UIGradientStyle)gradientStyle withFrame:(CG return [UIColor colorWithPatternImage:backgroundColorImage]; } + case UIGradientStyleDiagonal: { + + //Set out gradient's colors + backgroundGradientLayer.colors = cgColors; + + //Specify the direction our gradient will take + [backgroundGradientLayer setStartPoint:CGPointMake(0.0, 1.0)]; + [backgroundGradientLayer setEndPoint:CGPointMake(1.0, 0.0)]; + + //Convert our CALayer to a UIImage object + UIGraphicsBeginImageContextWithOptions(backgroundGradientLayer.bounds.size,NO, [UIScreen mainScreen].scale); + [backgroundGradientLayer renderInContext:UIGraphicsGetCurrentContext()]; + UIImage *backgroundColorImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + [self setGradientImage:backgroundColorImage]; + return [UIColor colorWithPatternImage:backgroundColorImage]; + } + + case UIGradientStyleTopToBottom: default: {