 <p>No matter where you put this code, you will need a reference to the view to get its bounds. You can either pass the view or bounds as a parameter or put it a UIView category or subclass.</p> <p>The UIColor class is just for creating colors, it has nothing to do with rendering or positioning them. That is a job for UIView. Therefore UIColor is not the place for this code imho.</p> <p>I suggest subclassing UIView and overriding drawRect to draw a gradient. Or create a UIView method like: <code>-(void)setBackgroundGradientWithStyle:(GradientStyle)gradientStyle colors:(NSArray *)colors</code> and put this code there.</p>