0

I wan to design a settings page, in which I have to draw lines between multiple labels, what is the best way to do this, I have googled around, got to know about CGContextRef approach. Is this the proper way, I need to have a line between labels (consecutively). Can I go ahead with this approach or any other best way is there.

Kjuly
  • 34,476
  • 22
  • 104
  • 118
Newbee
  • 3,231
  • 7
  • 42
  • 74

3 Answers3

1

I have given base view as dark color and I am adding labels as white, I am giving a line gap between two labels its looking like a line. No extra work :)

Newbee
  • 3,231
  • 7
  • 42
  • 74
0

May be just add UIView between labels? Something Like this:

UILabel *topLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
//Label settings
[self addSubview:topLabel];
[topLabel release];

UIView *separator = [[UIView alloc] initWithFrame:CGRectMake(topLabel.frame.origin.x, CGRectGetMaxY(topLabel.frame), topLabel.frame.size.width, 2)];
separator.backgroundColor = [UIColor blackColor];

UILabel *bottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(separator.frame), 320, 20)];
//Label settings
[self addSubview:bottomLabel];
[bottomLabel release];
Moonkid
  • 881
  • 7
  • 17
0

Couldn't you just create a custom UIView class with a UILabel and a UIView as the subviews of this custom view class?

class CustomView : UIView
{
    UIView *line;
    UILabel *label;
}

@property(nonatomic, retain) UIView *line;
@property(nonatomic, retain) UILabel *label;

For the UIView subview, you can tell it to use the width of the parent UIView.

Zhang
  • 11,549
  • 7
  • 57
  • 87