Under certain circumstances, UILabel seems to bring an extra word to new line even when there is enough space for it, for example,
If one more word is appended,
Even if I force the width of the label to become something like below, it still moves the word consists of "c"s to the next line,
I've tried twisting the configuration of the UILabel, but seems it behaves the same unless I set the line breaking mode to character wrap, below is the configuration for the above cases,
And the constraints (in the first two cases, the trailing ),
Is there any reason for this particular behaviour and can I fix this? It looks weird in this way leaving that space emptied.
this is the default behavior since iOS 11, to fix orphaned words. No way to shut it off
to fix it
use the text as attributed text
or
use UItextview and turn of the scroll, edit option
or
use the custom label here
Get each line of text in a UILabel
You should set the line break to character wrap, because the letters after the space will be recognized as a word.
Hey I know this is late but I just figured out that you can cheat the system by adding a bunch of spaces at the end of the text.
If text of UILable may be changed, then it's still possible to use quick-dirty hack with "\n" - new line symbol.
Text "Aaaaaaaaaaaaaa bbb cccccccccc\ndddddd" will force UILabel to display:
Aaaaaaaaaaaaaa bbb cccccccccc
ddddddd
In Interface Builder new line can be inputted with Ctrl + Enter
If u use wordWrap, it tries to keep words in full form, as a result of this, it goes to next line. If you use character wrap, it will break on characters, and push the chars onto next line.
For Example:-
My name is ABCXXXX and I (have space here)
love myself.
Solution:-
Use NSMutableAttributedText and write love\n. It will make the "love" be in the space myself in the next line.
I have a rather long String as an input in my report. It is desirable to represent it in a such way that every next line of this String is underlined.
Usage of style "underlined" doesn't help since it underlines words only and I want thewhole line to be underlined.
Using border doesn't do the trick as well since it shows one line only at the very bottom of the textfield.
Will be greatful for any help here.
P.S. Sorry for the excessive usage of word "line" here :)
I want to show the dotted line in front of the text (Same as Apple default Keypad Label).
Like as (....hi)
For iOS 6 use NSLineBreakByTruncatingHead of NSLineBreakMode.
From the docs:
NSLineBreakByTruncatingHead The line is displayed so that the end fits
in the container and the missing text at the beginning of the line is
indicated by an ellipsis glyph. Although this mode works for multiline
text, it is more often used for single line text.
For iOS < 6 you can use UILineBreakModeHeadTruncation of UILineBreakMode.
Dot will come automatically. if your text is big compare to label size. Then dot will come
automatically.
In Interface Builder: Line Break Mode -> Truncate Head
I need to get the two lines of content from uitextview, but without using nextline.. I entered the text continuously on uitextview without press enter the line goes to second line automatically. when I print those text it is showing single line. But the content is two or more than two lines. How I can get that content from UITextView.
You need to count (roughly) number of characters that can be entered in a single line.
Then using modulo and division you can find number of lines the text consumed.
Is there an easy way to have two lines of button.text where you specify each line individually? Also, there seem to be large margins on the buttons so the text font needs to be quite small to fit. Is there a way to allow the text to use more of the button area?
The way I would do a two-line text implementation is:
Dim t1,t2 As String
t1="This is line one"
t2="This is line two"
...
MyButton.Text = t1 & CRLF & t2
The CRLF performs a Carriage Return and Line feed thus splitting the text up
I can't help with the padding issue though. Have you tried changing the font size?
MyButton.TextSize=9