0

I have created a label programmatically.it's with is equal to the device width and I have aligned it to right.so it shows the text from right.enter image description here like this

titleLabel.textAlignment = NSTextAlignmentRight;

then I gave a text to the label.

titleLabel.text = @"Flight Summary";

but I want to keep a space after y letter in summary, without decreasing the width of the label.I tried with using string format like this.

titleLabel.text =[NSString stringWithFormat:@"%@  ", @"Flight Summary  "];

but nothing happned.how can I do that.hope your help for this.thanx.

caldera.sac
  • 4,918
  • 7
  • 37
  • 69

2 Answers2

0

To reduce the complexity of subclassing, you can take UIView and UIlabel, set frame of UIView to screen width and take UILabel frame as screenwidth - 8 (or whatever pixels is appropriate for you). Manage the frames and add both to mainview, this way you will be able to achieve the look.

Milan Gupta
  • 1,181
  • 8
  • 21
-1

Try this

titleLabel.text = @"abcd exadgdf    \u{200c}""

You can also do one more thing. You can use attributed string and set attributed text to titlelabel without formatting string like this

NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"ABCD      "];

titleLabel.attributedText = attrString;
Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81