Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Add clockWise boolean property to set direction of drawing. #16

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions AngleGradient/AngleGradientLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@

@property (nonatomic) CGFloat startAngle;

//Set direction. Default is NO ( counter clockwise)
@property (nonatomic) bool clockWise;

/* The core method generating gradient image.
*/
+ (CGImageRef)newImageGradientInRect:(CGRect)rect colors:(NSArray *)colors locations:(NSArray *)locations;
Expand Down
8 changes: 8 additions & 0 deletions AngleGradient/AngleGradientLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ - (void)drawInContext:(CGContextRef)ctx
{
CGContextSetFillColorWithColor(ctx, self.backgroundColor);
CGContextRotateCTM(ctx, self.startAngle);
if (self.clockWise)
{
CGAffineTransform flipHorizontal = CGAffineTransformMake(
1, 0, 0, -1, 0,
self.bounds.size.width
);
CGContextConcatCTM(ctx, flipHorizontal);
}
CGRect rect = CGContextGetClipBoundingBox(ctx);
CGContextFillRect(ctx, rect);

Expand Down