Hi I am new to iPhone development. I want to resize my label. I know this question asked many times previously but those answers not working for me. I don't know what I am doing wrong. I did following things : I am using auto layout. I also define number of line to 0. then to resize my label I did following things
NSString *text = @"NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID NILESH KASHID “;
_sampleText.text = text;
CGRect newSize = _sampleText.frame;
newSize.size.height = 200.0f;
_sampleText.frame = newSize;
I tried [_sampleText sizeToFit];
this also.
But this not working for me. Any one can help me please. Need Help. Thank you.
I tried this one
CGSize maximumSize = CGSizeMake(_sampleText.frame.size.width, 999);
CGSize expectedSize = [text boundingRectWithSize: maximumSize options: NSStringDrawingUsesLineFragmentOrigin
attributes: @{ NSFontAttributeName:[UIFont fontWithName:_sampleText.font.fontName size:_sampleText.font.pointSize] } context: nil].size;
[_sampleText setText:text];
[_sampleText sizeToFit];
CGRect rect = _sampleText.frame;
rect.size.height = expectedSize.height;
_sampleText.frame = rect;
Forgot about text and resizing with text I am not able to resize Uilabel it self
CGRect rect = CGRectMake(0, 0, 50, 50);
[_sampleText setFrame:rect];
above code inside viewDidLoad.
So I found some thing. If I disable auto layout option then it works fine. But what if I want to use it with auto layout enable?