Search code examples
iphoneiosuitableviewaccessoryview

How can I create an accessory view for my table cell like this?


Basically I need two labels. one with a number and other with the constant string letters on next line.Also I need a speech bubble as background for accessory view.I know how to create one label , but no idea about setting two label as accessory view. Please help

enter image description here


Solution

  • You can create a UIView and add all the necessary views to it as its subviews, then make that single view the accessory view of the table view cell:

    UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
    [container addSubview:backgroundImage];
    [container addSubview:firstLabel];
    [container addSubview:secondLabel];
    cell.accessoryView = container;