Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Smooth Color Change Transition/Animation

Tags:

I want to have a smooth color transition that goes across the entire spectrum (i.e. red, blue, green, yellow, orange, etc.)

Also want to be able to have smooth transitions of colors in specific spectrum (i.e. all reds).

Are there any simple algorithms/recursive functions/formulas that can help simplify this process?

like image 236
JimmyJammed Avatar asked Nov 05 '13 03:11

JimmyJammed


1 Answers

One very simple way to accomplish this would be to use a UIView animation block.

[UIView animateWithDuration:1.0 animations:^{     view.backgroundColor = [UIColor redColor]; }]; 

This will interpolate between whatever view's previous background color was, and red over the course of 1 second.

Swift:

UIView.animate(withDuration: 1.0) {      view.backgroundColor = .red } 
like image 163
dalton_c Avatar answered Oct 14 '22 21:10

dalton_c