Search code examples
iosgradientxcode-storyboard

How to add gradient background color to prototyped UITableViewCell in storyboard?


Is there any way to add a gradient to prototyped UITableViewCell in storyboard? To be specific, I want to allow users to add custom photos to the app and that photo will be displayed in the cell as a background. But there will be some labels above the image. So I want to add a gradient to the bottom of the cell to make labels always visible (regardless of background photo).

I know that this is possible programmatically, for example I may use CAGradientLayer like in this tutorial: http://www.cocoawithlove.com/2009/08/adding-shadow-effects-to-uitableview.html
or this: http://www.raywenderlich.com/32283/core-graphics-tutorial-lines-rectangles-and-gradients

But I am wondering if there is any way to do that just in storyboard.

Thanks.


Solution

  • As far as I know, there is no way to do this from interface builder.

    Some things are just too complex to put a decent UI on it.

    A neat little workaround would be to create an IBDesignable IBInspectable UIView subclass that programmatically does what you desire, than use that in your storyboary scene.