Skip to content
This repository was archived by the owner on Jun 13, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Pod/Classes/Objective-C/UIColor+Chameleon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand Down
20 changes: 20 additions & 0 deletions Pod/Classes/Objective-C/UIColor+Chameleon.m
Original file line number Diff line number Diff line change
Expand Up @@ -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: {

Expand Down