How to add gradient at bottom of UITableViewCell as Tweetie app

Does anyone know how:

  • add a slight gradient to the bottom of each UITableViewCell to visually highlight the separation between the cells.
  • and at the same time make every second cell in the table slightly darker than every first row.

The Tweetie app is a great example of this. When you click on your Twitter account name, you will see a tabular view with twitts. Even the lines are a little lighter, and each row has a tiny dark gradient at the bottom that visually separates the lines. Looks good.

Can anyone give me some hints on how to do this?

+2


source to share


2 answers


I'm not sure if this is what you want as I am not using Tweetie (although it made sense to check it out), but Cocoa Love has a good discussion of the new CAGradientLayer available in 3.0. And the older one, which relies on custom background images behind the cells.



+1


source


I haven't looked at Tweetie. You can add a UIImageView to your cells above other elements, with a gradient image and an alpha of 50% or less. With the correct gradient and alpha, that will make the top and bottom of each cell look different - sort of like every cell is curved.



If you want every other cell to look different, then in cellForRowAtIndexPath add a different color gradient in the UIImageView above, for odd cells and even for cells. Or change the background UIColor for the cell.

+1


source







All Articles