Any way to alter text attributes within a UITextField? - iphone

Simply stated -
I want to have a scrollable text field with a paragraph of text. Some of the sentences should be bold and blue while others are red and normal, while the remainder is simple black/normal text.
Any way to alter the text attributes 'within / amongst' the text?
Thanks!

A lie for your sanity: no, you cannot
do this.
The truth (use with caution): You can
create attributed strings... using
core text (but just don't even bother
lol - its not worth it).
The compromise: Use a UIWebView and
HTML. :) Can't say fairer than that.

Related

How to insert keyboard key graphic representations into your document?

I'm working on a document describing keyboard shortcuts in GNOME and want to make text better looking than: ALT + TAB. A common way seems to be like in this thread where the buttons appear to be within the text:
https://unix.stackexchange.com/q/465681
Is this possible in LibreOffice in a proper way, or is it just inserting images inline? That doesn't seem like it would work every well with changing font size, etc. later, so I was hoping for a better solution.
You could insert real push buttons that don't do anything by following steps 1 thru 6 outlined at https://help.libreoffice.org/Common/Inserting_and_Editing_Buttons. But that approach, as well as inserting inline images, would be awkward because you'd have to worry at least about sizing, anchoring, and wrapping of surrounding text.
The approach you appear to be trying to avoid seems much more palatable, so long as you're not looking to exactly duplicate to Stack Exchange look.
As an example to demonstrate that it's workable, I did the following by applying the same Character formatting settings to each key word. This involved changing font family and size, setting light gray highlighting, adding a gray border, and changing left and right border padding from 0.02 to 0.06...
To make things easy, the settings could all be done with a single button press by creating a macro that could be applied to selected text. And since the result is just formatted text, there are no sizing, anchoring, or text wrapping issues to worry about.
One other option, as an alternative to significant text formatting, is to acquire and use a keyboard font, such as that discussed at How is the Keyboard font automatically styled as keyboard-like keys for the letters in Alt, Shift, Ctrl, Esc, and Backspace?. That would only require changing to that font to type in key representations.

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

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.

how to use paragraph text in uitableviewcell in cocoa-touch

I've been using uiLabels to put text in the cells of tableviews. I want to now use paragraph text that carriage returns to the next line instead of going out of the boundaries of the table cell. Would I do this by manipulating a uiLabel or would I use a different control all together like a text view.
Also is there any project examples out there that implement this?
Thanks,
Joe
Simplest way is to use a UILabel and set the number of lines in IB to > 1 then set the line break to "Word Wrap."
Another way is to use a UITextView, load the data and set it to 'disabled' so it can't be edited.
Finally, you can always go the UIWebView route and load it with formatted HTML, complete with line breaks, etc. Pretty heavy, but most flexible.
The simplest approach is to use a UILabel, probably. The only alternative would be to make a custom UIView subclass that draws the text directly, but that will give you marginal benefit.