tobihagemann / THLabel

UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.
https://tobiha.de
Other
665 stars 111 forks source link

THLabel not fitting Label Box #25

Closed sambudda closed 8 years ago

sambudda commented 9 years ago

I have defined a THLabel programmatically as follows.

THLabel *labelValue4 = [[THLabel alloc] initWithFrame:CGRectMake(20,269,300,85)]; labelValue4.text = @"Spectacular"; labelValue4.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size: 57.0]; labelValue4.textColor = [UIColor colorWithRed:52/255.f green:152/255.f blue:255/255.f alpha:1.0]; labelValue4.textAlignment = NSTextAlignmentLeft; labelValue4.numberOfLines = 1; labelValue4.backgroundColor = [UIColor clearColor]; labelValue4.strokeColor = [UIColor blackColor]; labelValue4.strokeSize = 1.0; [self.view addSubview:labelValue4];

What I want is if the word is large like "spectacular" then it should adjust the size of the font automatically but it doesn't. It just chops off the word. How can I fix that? By the way really nice with THLabel. ios simulator screen shot sep 26 2014 5 47 47 pm

Or I get this for labelValue4.text = @"Partly Cloudy"; dot dot dot ios simulator screen shot sep 26 2014 6 10 30 pm

tobihagemann commented 9 years ago

This is definitively a known issue. THLabel is using Core Text for drawing and I'm not aware of a simple solution like UILabel's adjustsFontSizeToFitWidth or minimumScaleFactor. Also numberOfLines is being ignored by THLabel. I'll look into this issue again, but I couldn't find anything the last time. The solution for now is probably to set a fixed lower font size.

pronebird commented 9 years ago

Does THLabel support adjustsFontSizeToFitWidth?

tobihagemann commented 9 years ago

As I've mentioned unfortunately not, sorry.