Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the label height after ResizeToFitText? #18

Open
HellCloud opened this issue Oct 24, 2012 · 2 comments
Open

How to get the label height after ResizeToFitText? #18

HellCloud opened this issue Oct 24, 2012 · 2 comments

Comments

@HellCloud
Copy link

Hi guys,

here is my code

MTLabel *label3 = [MTLabel labelWithFrame:CGRectMake(20, 240, 250, 1) 
                                  andText:@"This label was resized to fit text inside it"];
[label3 setTextAlignment:MTLabelTextAlignmentCenter];
[label3 setFont:[UIFont systemFontOfSize:20]];
[label3 setResizeToFitText:YES];
NSLog(@"%f", label3.frame.size.height);
[self.view addSubview:label3];

I want to get the label frame size , but the value of NSLog output is always 1.000000
How i get the label frame size after resize ?

Thanks guys.

@campinooo
Copy link

Hi,
there is a delegate function which is called after resizing the label (labelDidChangeFrame).
The function returns the new size of the CGRect of the label.

@HellCloud
Copy link
Author

it's work!, Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants