Why does the Label text not always start from the same point? - iphone

I have a UILabel which has 4 lines. Its font size is 15 & autoshrink is enabled. It's minimum font size is 10.
When my text is too long then it automatically starts from first line. But when my text is too small then it starts from middle line.
How can I make sure the text always starts from first line, whether it's too long or too short?

I think what you're looking for is more a UITextView than a UILabel.
From Apple's doc :
UITextView displays a region that can contain multiple lines of editable text.
The editable part is optional. You can disable it, along with scrolling if you want to be close to a UILabel.

Related

Text component displaying lines in reverse order

Alright, I do not know how to fix this and only ran into this problem after trying to put in some longer text on a UI Text component. I have tried both pasting a value into its Text attribute through the Unity editor, and setting its value programmatically like this:
t.GetComponent<Text> ().text = "This is where meat, fish, and [...] (long text)"
Because Horizontal wrap is on, the text wraps when it reaches the edge of the available space.
However, the text displays backwards. Meaning, the start of the paragraph is at the bottom, and bottom at the top. Taking off wrap fixes this, but then the font size has to be really small (or it won't all be visible), and it can't form a normal paragraph because it has to... you know... wrap.
Is this a bug in Unity?
This is what happens - as you can see, it is displayed backwards:
The negative Line Spacing value is what is causing the issue here:
When the value of this field is less than 0, the lines will actually be arranged backwards, leading to the behaviour you're currently encountering. Just change the value to a positive number to have the text display correctly.

Devide text to UITextViews

I have long text and 2 textViews.
I need to insert this text to 2 textViews(they have no scrolling).
It's like book pages(first page is a one textView, second page is a another textView).
So, question is: how to determine which text length I need insert to first textView?
You can set the complete text to the first textView, calculate the visible text range and set the remaining text to the second textView. An alternative is to manually calculate the range of the text that will be visible in the first textView, however it requires ugly recursion with sizeWithFont that i can't believe is so fast, i'd follow the first way.
See this answer to learn how to get the visible text range.
First figure out length of each line, font, and how many lines you can fill into the each textview. Use following to do this
CGFloat stringWidth = [text sizeWithFont:[UIFont fontWithName:your_textview_font_name size:your_textview_font_size]].width;
Then use substrings operation.
Shouldn't be difficult to do this!

How to have one view support portrait and landscape

I have one view in my app that has a lot of writing on it.
It's important that this writing stay in the "one lines" that it is.
The problem is sometimes each line changes length causing the text to scale down in size.
So how would I make this view also supporg landscape?
You have three choices :
1) Let the text span more than one line
2) Truncate the text instead of scaling it
3) Accept that the text is going to scale.
You've already said in your question that you don't want (1) or (3) so you need to do option (2).
You can turn off text scaling by setting this on your label :
myLabel.adjustsFontSizeToFitWidth = NO;
and choose how you want the text to be trucated, for example this :
myLabel.lineBreakMode.UILineBreakModeMiddleTruncation;
will trim from the center of your label i.e. 'This_is_..._text' - it adds the ... for you instead of scaling the text.

Display text with one word appearing after another word effect

I want to display a label or uitextview with text in a manner that text will appear slowly with one word at a time. I mean first it will display first word then second and then third and so on…
I'm not familiar enough with core-animations, but this could be acheived by using a simple NSTimer and on each interval append the UILabel's text

Break a text in a label in iphone

I am new to iphone development.I have created three labels in a cell and i have just displayed the text in the corresponding labels , but i want to display the full text in the label.I am not able to see the full text,So is there any possibility for breaking the text and show them in two lines.I am not displaying any static text .I am getting the text dynamically from the website and displaying it in the label.Please help me out.Thanks.
set label's numberOfLines property to 2 (or to 0 to have any number of lines you need)
set label's lineBreakMode property (e.g. to UILineBreakModeWordWrap)
make sure that label's height is enough to contain 2 (or more) lines of text