UILabel text gets truncated with large font size - ios

The text inside my UILabel in Interface Builder is being truncated when the text is a large font size. The UILabel does scroll vertically when the characters exceed the viewport size, but at one point the text is simply truncated. Can anyone advise?
The element hierarchy is: Scroll View > View > UILabel
UILabel AutoLayout properties are set to:
Lines: 0
Line Break: Word Wrap
Autoshrink: Fixed Font Size
I would prefer to keep everything in AutoLayout rather than set the properties programmatically.

You are set the property of Label. So that according to device its set font size is auto.
Autoshrink : Minimum Font scale
Scale : 0.7

You can use both **Minimum font Size** &&Minimum font Scale`

Related

UILabel height depending on font size

I am using a UILabel in a UITableViewCell to display a title. Normally the text is not too long and therefore the font size can be large. Notice how the text fills the height of theUILabel like normal.
However, when there is a larger title, I want the UILabel height to reduce to accommodate the smaller font size and not leave a blank gap in its place. Currently, my configuration produces this effect.
I am using constraints in my storyboard and have deliberately not set a fixed height constraint. Here are the relevant constraints added:
I may have made a rookie error in my configuration as I can't remember this effect happening before, but it is giving me real headaches (and a bad looking UI).
When UILabel is set to auto-adjust font size to fit, it does NOT auto-adjust the height of itself.
You have a couple options:
set Baseline to Align Centers, and just accept that you will have top and bottom padding
use code to calculate the "scaled font size" and update the font size of the label
Remove either the Top Space or Bottom Space constraints (depending on where you want the label to be anchored).
This will cause the label to automatically use fit itself to the text size.
Try this and see, it should work according to your need:
Set Top and Bottom constraints attribute Greater Than or Equal To and add horizontal center (Alight Center Y to superview) and show in this image.

iOS10 UILabel use NSLineBreakByCharWrapping has half character ,how to fix it?

this is UILabel show half character!!!
this is UILabel attribute!!!
The Linebreaking is only working if the label have the chance to break the line. But with "Lines" set to 1, there is no chance.
Set the Lines to 0 (auto) or at least to 2 and it will work.
just set auto shrink to minimum font scale from storyboard so it will automatically set the size of font according to the label width or programmatically set [self.yourlablename sizToFit]

determining height to be set based on font size in iOS

In IOS, we have height and font size for UI label.
When I add a uilabel to the screen, I see a default height and font for it and height is always bit more than the font size to take care of ascenders and descenders. But when I increase the font size in design time, the height still remains at where it was when it was added to the screen. So, how to I decide during design time what is the appropriate height to be set if I change the font size to what I want.
Edit the text of the label and press enter, it will take it's size
Click your label in the canvas so that you get its resize handles. Then, from the menu bar, choose Editor > Size to Fit Content. The default shortcut is ⌘=.

Adjust UILabel size based on size Swift

I'm trying to adjust my label size based on screen size using swift. I'm using the dynamic layout and cannot figure it out. Essentially what I am looking to do is shrink the text/font size to fit within my frame.
You can do this all in the storyboard.
Add constraints between the leading and trailing edges of the label and its superview. (Something like |-[label]-| in the visual format.) This will adjust the width of the label as the width of its superview changes.
If you want the font size to adjust as well, you can set the Autoshrink item in the storyboard to Minimum Font Scale and set an appropriate value (0.5 is the default).

UILabel AutoShrink property in not working in ios 7

I added Autoshrink Property of my label from nib file as follow;
It is working good in ios6 but not effected in ios7.
ios6:
ios7
Why this happen? I am using numberoflines=2
Help to solve this
Thank you
Yes that is because you are using
numberOfLines = 2
that means your label will be of two lines, so its auto adjusting the size accordingly as your label will be of 2 lines,
set background color of the Label to get to know about the label dimension.
EDIT -
If you want your labeltext to fit someother Superview element accordingly and have thinking that your label can have a text too long, then set numberOfLines = 0.
Basically numberOfLines means the Maximum line breaks the text of the label can have
Set your FONT to a lower value - 14,13 (judging by your previous one that is what i am sensing)
Set your Label to a fixed width, so that you know that a nextLine would appear after that width,
Set Number of lines to 0

Resources