Word cutting off between lines in button - swift

I have buttons that can hold multiple lines of text (title). However, occasionally, the words or numbers would cut off between lines. It is also good to note that I am getting the text for the button's title from a Database.
How do I make it so that the word would just go down to the next line?
Here is an example:

Set the button's Line Break mode to "Word Wrap" in your storyboard.
If setup by code, set the lineBreakMode of the button's titleLabel property to .byWordWrapping.

Related

New line on UILabel messes with the word wrapping [duplicate]

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.

How to add padding to symbol text in Visio 2013?

In Visio 2013, I have a connector that is in a container that has a gray background color. I successfully changed the background color of the text block by following these steps:
Double-click the connector
Expand the font options by clicking on the icon in the lower-right portion of the 'Home > Font' ribbon area
Click on 'Text Block' tab in the 'Text' dialog
Select 'Solid color' and choose the background color that matches the gray container background color
That works as expected - my text background color is no longer the default white; it now matches the background color of the container.
However, I want to add spacing to the left and right of the text. I tried increasing the margins in the same 'Text Block' tab of the 'Text' dialog mentioned above. This increased the margins but did not extend the background color of the text. A also tried manually adding spaces to the left and right of the text. The leading spaces worked, but the trailing spaces where truncated. Is there any way to add left and right padding to the text (similar to css padding)?
Modifying the text block location/size may give you what you want, combined with text margins.
To modify the text block location, you have to click the text block tool, which is on a dropdown with the text tool (at least in Visio 2003).
I know this is an old question, but I had the same question myself and wasn't able to (quickly) find an answer out there either. I finally hit upon a trick that'll get the result we're looking for:
Instead of spaces, add leading and trailing characters to the longest line in the text box. (I use ".")
Change the color of ONLY those added characters so it matches the text box's background.
The text box's background reaches to the furthest edge of the text within, and we're just using that to get what we want. Since it's just moving the edge indirectly, I consider it a "trick" that we can use instead of a "fix".
Quick list of Cons:
The text box background color has to be solid, or close to it.
The "invisible" text will still exist, so it'll show up in a copy/paste of the text.
Similarly, it may make Searching/CTRL+F for things within the document/file more difficult.
You can use No-Break Space. Insert it from Insert > Symbol.

How to set a UITextField to edit severals lines?

I have a UITextField that is 300px width and 270px height. When I want to edit it, the cursor goes automatically in the middle and I can only write on the middle line.
How can I set this UITextField to have severals lines and a cursor starting at the top-left ?
Simple answer, just use UITextView instead.
UITextfield is designed for single line only, If you want to enter multi line text than use UITextView instead and set its editable property to YES than it would behave like textfield!
[myTextView setEditable:YES];
Note: You can also set it via Interface Builder, select the "editable" box & It will be multiline by default.

UITableView cell multiline justification

I have seen questions posted on here asking how to left and right align two lumps of text, but how can I neatly left and right justify an entire paragraph inside a multiline cell? (Such as what MS Word etc would do if you click on the justification button so that left and right sides of the text are always aligned).
You can also create a custom cell with label which IBOutlet to this class that can be downloaded on github OHAttributedLabel, then try the code below
cell.label.textAlignment = UITextAlignmentJustify;
Is this what you're looking for?
yourTextLabel.textAlignment = UITextAlignmentCenter;
Along with the frame size that you want for your text label.

How to display multi-line text without scroll in UIView?

I have multi-line non-HTML text (with newlines). Need to output it inside ScrollView or just UIView.
I can't output it as UITextView: can't find how to resize UITextView to the size of text and/or disable scroll in it.
Should I output text to Label?
Or there's something more proper for that?
Thanks.
Try using a UILabel, then set the lineBreakMode property to UILineBreakModeWordWrap, and the numberOfLines property to zero (unlimited lines).
Depending on the style of text you're using, you might try stripping out the newlines so the result looks better.