Skip to content

dmcrodrigues/DREasyGradient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DREasyGradient

This project is just an helper with a minimal API to create gradients easily on iOS applications.

image

Usage

To use DREasyGradient you just need to import the folder DREasyGradient/. This folder contains the header and the source code.

API

// create a gradient with multiple colors
+(CAGradientLayer *)gradientWithFrame:(CGRect)frame
                          orientation:(DRGradientOrientation)orientation
                               colors:(NSArray *)colors

// create a gradient with just two colors
+(CAGradientLayer *)gradientWithFrame:(CGRect)frame
                          orientation:(DRGradientOrientation)orientation
                               color1:(UIColor *)color1
                               color2:(UIColor *)color2

// create a gradient with multiple colors
+(UIImage *)gradientImageWithFrame:(CGRect)frame
                       orientation:(DRGradientOrientation)orientation
                            colors:(NSArray *)colors;

// create a gradient with just two colors
+(UIImage *)gradientImageWithFrame:(CGRect)frame
                       orientation:(DRGradientOrientation)orientation
                            color1:(UIColor *)color1
                            color2:(UIColor *)color2;

You can control the gradient orientation using DRVerticalGradient or DRHorizontalGradient.

Example

CGRect frame = CGRectMake(10.0, 30.0, self.view.frame.size.width - 20.0, 50.0);

NSArray *colors = [[NSArray alloc] initWithObjects:
                   [UIColor redColor],
                   [UIColor orangeColor],
                   [UIColor blueColor],
                   nil];

gradient = [DREasyGradient gradientWithFrame:frame
                                 orientation:DRVerticalGradient
                                      colors:colors];

[self.view.layer addSublayer:gradient];

Dependencies

  • QuartzCore.framework

Licence

MIT License

About

Simple API to create gradients on iOS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published