In my application I want to draw UILabel dynamically depends upon string in DrawRect method...How can draw this?
Asked
Active
Viewed 576 times
2 Answers
0
You want to change the UILabel frame according to your textSize?? If so, refer this post.

Community
- 1
- 1

KingofBliss
- 15,055
- 6
- 50
- 72
0
Try the code below..
It worked for me in the case of button title. :)
CGRect oldLblRect = lbl1.frame;
lbl1.titleLabel.font = [UIFont systemFontOfSize:15];
[lbl1 sizeToFit];
lbl1.frame = CGRectMake(lbl1.frame.origin.x - ((lbl1.frame.size.width - oldLblRect.size.width)/2), lbl1.frame.origin.y - ((lbl1.frame.size.height - oldLblRect.size.height)/2), lbl1.frame.size.width, lbl1.frame.size.height);
Hope it helps. :)

Shrey
- 1,959
- 2
- 21
- 44