0

I customized UITableView for two columns that have different background colors with background images.

I used three images, first image is top cell bg, second is middle cell bg and third is bottom cell bg for round border.

But the text contents in column can be multiline, and table must have round rect border.

See example image.

I want to implement this table

I tried customize cell for that. But first and round cells does not have rounded border.

See customized cell image. (It does not have rounded border.)

customized cell but that does not have rounded border

How can i customize UITableViewCell for implement like that image without using multiple background images?

Danil Chernokalov
  • 755
  • 1
  • 10
  • 31

4 Answers4

1

You can simply use custom UITableViewCell

Check this tutorial: http://www.appcoda.com/customize-table-view-cells-for-uitableview/

Mohammed Habib
  • 606
  • 5
  • 10
  • I placed two rectangle labels for that. And i set two label for having diffenrent background color. But how can i implement rounded border for first and last cell? – Danil Chernokalov Feb 18 '13 at 07:55
  • You can implement -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath and modify the about-to-render cell based on its index. – Mohammed Habib Feb 18 '13 at 07:59
  • Alternatively, you can use different custom cells for first and last cells. – Mohammed Habib Feb 18 '13 at 08:02
  • But if i customize first and last cells, i must use rounded-border background image for two columns. Is there any other method without using rounded border image? – Danil Chernokalov Feb 18 '13 at 08:05
  • Check this post http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how – Mohammed Habib Feb 18 '13 at 08:15
1

Create Custom UITableViewCell and Make as Your wish and change size and use label for text.

1

Hey please look at below scenario for more information.

check this screenshot.

enter image description here

And code style as like.

Two Imageview and two UIlabels are inside of every cell.

So need to create one custom cell and add in UITableView,

Please take a look on this Custom cell helpful link : Blog Link

Let me know if you need any more information relates to code.

Solid Soft
  • 1,872
  • 2
  • 25
  • 55
  • Thanks. But i need two full painted columns. If i placed two imageview and uilabels, i think first and last cells does not have round-border. Can you tell me more detail? – Danil Chernokalov Feb 18 '13 at 08:10
  • 1
    Yes you are right. You need images as like, First - Middle - Last. First with Top rounded corner. Middle does not have rounded corner. Last has bottom rounded corner. Hope it helps.. – Solid Soft Feb 18 '13 at 10:27
0

You can create a custom class extending class UITableViewCell. Insert two image views in them using the required frame. Make them a property and then assign them the intended image or background color in method cellForRowAtIndexpath:. If you require to give only different background colors and not image then no need to use UIImageView. A simple UIView will also do the task

Yogi
  • 3,578
  • 3
  • 35
  • 56
  • But how can i implement rounded border for first and last cell? – Danil Chernokalov Feb 18 '13 at 07:54
  • You can addsubview the views in your cell such that the X is a little lesser than zer e.g. -1, -2 etc. and then set **clipToBounds** proprty of your cell to YES. – Yogi Feb 18 '13 at 09:41