Skip to content

janselv/smooth-gradient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iOS Smooth Gradients using Penners's Easing Functions

This project use the Swift Penner's Functions to draw gradients that interpolate not linearly, creating a smooth effect. Easing functions vary the rate at which gradient shading changes. Depending on the function you select, they provide gentler transitions into and out of the gradient.

Tweaking gradients we can turn the first image into second using these functions.

Regular Smooth

Usage

let c1 = UIColor(white: 0, alpha: 0)
let c2 = UIColor(white: 0, alpha: 1)

let gradient = CGGradient.with(easing: .easeInCubic, from: c1, to: c2)

// for less pronounced beginning try
let gradient = CGGradient.with(easing: .easeInQuad, from: c1, to: c2)

You can also play with other esing function or write your own.

Supports iOS 7+

About

Swift CGGradient extension to smooth gradients into a gentler transition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages