The same number of characters in each line of UITextView? - iphone

Hi I'm developing a simple writing program using UITextView to study Cocoa programming.
In UITextView, each line has different number of characters.
I tried to change fonts of UITextView, but the width of each character seems to vary. For example, l and L has different width.
Is there anyway to keep the same number of characters in each line of UITextView like emacs or just like this editing box of stackoverflow?
Thank you so much.

easiest way is to use a monospaced font like Courier New

Related

text-align-last css property Swift Equivalent

What is the swift Equivalent for 'text-align-last' css property?
I prefer a codeless solution.
Here is what i have done and what i get:
The last line (sometimes the only one) is aligned to the left, which is inconvenient.
You need to change the label's text from Plain to Attributed, then you can paste any string and the alignment, as well as other attributes, will hold.
So basically any text style that can create on word processor application can be used here.
In the following example I've used pages (Mac application) to edit the text format as I liked and copied it to the label text box in Xcode.
Here is a picture of the simulator running the app:
While it is not possible to apply different aligns on a single label, if the last(and sometime only) line should be aligned to the right why not align the entire label to the right?
EDIT
If that doesn't fix you problem then I don't think it's possible to resolve without code.
In the case you do decide to write some code you could look into determining which is the last line of your string (maybe: How to get text from nth line of UILabel? ) and try to apply different formatting with AttributedString.
If that works then you can always subclass UILabel and override func layoutSubviews() to calculate this automatically for you. This way you won't have to think about it again!

Watch App - Replace ... when text is too long

I have a problem with the size of my text.
When my text is too long in a WKInterfaceLabel, no problem, I just add line or I pass line at 0 to increase automatically the number of lines.
But with WKInterfacePicker, impossible to increase the number of line and I have "..." at the end of my text.
Do you have solutions to display all my text or, at least, to delete this "..." and replace it by some letters more from my text. I work with Swift.
For the second solution, I prefer have "My text" than "My te..."
Sadly, this is not possible. Apple doesn't provide any sort of way on managing that.
A possible, but rather complicated solution would be making a costume picker with labels with multiple lines and using the newly implemented WKCrownSequencer as well as the WKCrownDelegate in watchOS 3 to detect the state of the digital crown. The default picker animations might be impossible or very difficult to reproduce, but it might fix your problem.
try this set in size width = size to fit width content

In UILabel dotted line is show front in iOS ?

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

iPhone SDK - UITextView text color split

I have a UITextView that I would like be be able to change the color for. But I would like to be able to change the color only after 50 characters. I can use UITextViewDelegate methods to count the characters, but I'm not sure how to change the color after that.
For instance, when I have a 100 character phrase within the UITextView, I would like the first 50 characters to be blue, and the last 50 characters to be red.
Is this possible? Any advice on how to achieve this?
Many thanks,
Brett
It is possible, but not via native UITextView or so
read more here:
http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
http://www.scoop.it/t/iphone-and-ipad-development/p/104023127/rtlabel-rich-text-formatting-for-ios-using-html-like-markup-coding-for-mobile
http://iphoneincubator.com/blog/windows-views/display-rich-text-using-a-uiwebview
like #Nekto said
You can set only one color for all characters in one text view, using textColor property. If you want different colors in one sequence of characters, you can use, for example, UIWebView and html tags.

Different the width of whitespace in eclipse editor

I set my editor use the whitespace only, but I got problem with the whitespace's width. The longer whitespace in blank lines, shorter in others. I have no idea how to configure it.
You are using a variable width font. Change it to a fixed width font like Courier New/Consolas/Monaco/Menlo (depending on your preferences)
Go to Eclipse->Preferences->General->Appearance->Colors and Fonts->Structured Text Editors->Structured Text Editor font and set it to a fixed width font
If you do want to use a variable width font, just make all those fonts/colors use the same size.
Monospaced fonts are only used because editors still don't support relatively recent inventions like elastic tabstops which results in the type of issue you highlight. That plus habit.
I personally find that variable width fonts look so much better and increase the readability so much that they're totally worth it.