How do you add uneditable text in an iOS app - ios

I now a label can create static text, but I have a few paragraphs that are neatly formatted that need to go to my app. How can I do this without using a label?

You can use a UITextView and set the editable property to NO

Related

Detect link attribute and callout as link for NSAttributedString in iOS

I have a link within an attributed string that is being then set for a textview. For Accessibility purpose, I want that link to be called out as a link trait, is it currently possible for an attributed string to call out different traits within the string? If not what could be an ideal solution to do that then?
You can look for all the "style runs" of attributes within the text view's attributed text by calling attributes(at:longestEffectiveRange:in:) repeatedly until you come to the style run you want. Thus you can locate the link and obtain its value.

Custom iOS keyboard - Custom font output

I am trying to create a custom keyboard using the app keyboard extension. I am happy with the layout but the output is depended on the UITextField's font.
Is there a way to force a different font (use special characters?) while using the keyboard ?
Thank you
It depends.
Text field (or any other view that draws text) uses 2 informations on how to show some text. One is the sequence of characters called String and the other one is how the string should be represented. The second one is then split it things like fonts, colors, line height, line breaking and wrapping...
So the keyboard alone is not enough to for instance present a certain part of word using different fonts. You need at least a bit of access to the item that represents the text. So if you have no access to your text field then the answer is; No, you can not fore a different font when using different keyboard.
If you do have the access then the answer should lie in NSAttributedString. It is a string you can assign to most items under attributedText. This class wraps your raw string and can add many properties to parts of text you want to change. That includes using a different font.
Another approach would be using HTML tags. Again you will need to process this using for instance NSAttributedString or display it with another element like web view.
I would try it with using NSAttributedString. Hook up to delegate and implement textField(: shouldChangeCharactersIn: replacementString:. The implementation itself may still not be easy though.

Custom bulleted text in UITextView

I need square bulleted(colored) text as follows
◼︎ Some large amount of text that
make it span to the next line.
to be shown in UITextView. But the problem is it doesn't git the padding on the next line.
◼︎ Some large amount of text that
make it span to the next line.
These bulleted text is of static content and hence no need to set it through code.
Also custom font is not working when I set attributed type. Custom font used is Raleway.
You need to set up a ruler with a "hanging indent." I have no idea how to do this manually with text attributes.
I would suggest instead setting up what you want in a .rtf file and then loading an attributed string from the RTF using either initWithURL:options:documentAttributes:error: (which is only available in iOS 9 or later) or initWithData:options:documentAttributes:error: (which is available in iOS >= 7.0.)
You specify an options dictionary of
Objective-C:
#{NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType}
Swift:
[NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType]

How to display text on iOS

I'm new to Xcode an trying to design a basic text app. I'm wondering what the best way to display mutable text that cannot be edited by the user. Thanks for any help.
Depending on how much text you want display
1) UILabel for short things...won't be editable
2)and UITextView for large texts (set editable property to false)

iOS: URL link in UITextField with different text

I want to insert a URL hyperlink into a UITextField that has different display text.
This is super easy in html:
Go To Google
How can I do this in iOS?
You can change the text style inside your UITextField via an attributed string sent to the text field's "attributedText" property.
However, what I suspect you really want to do is have a link that's clickable. I would recommend using a UIButton with a custom type (i.e. no border) and you can set the color and the underline style.
But like Evan said, if you have multiple lines of text, it may be smarter to use a UITextField where you set "editable" to NO and turn on the LINK traits (both of these you can do from the object inspector in Xcode).
Alright, so here's what I did to get what I wanted. I used UIWebView, and simply linked it to an html page in the project that has the text, and hyperlink at the bottom with different text displayed.
Answer is here :
If you want it as clickable Hyperlink,
NSString *string = #"Go To Google";
You need to add "BACKWARD SLASH" before ". That's it.

Resources