How to add Underline/Bold/Italicize Abilities for UITextView Swift [duplicate] - ios

This question already has answers here:
How to add toggleBoldface option to a UITextView in iOS?
(2 answers)
Closed 5 years ago.
I have been searching for quite a while for a solution as to how to grant users the ability to underline, italicize and bold text in a UITextView but have not been able to find a solid solution. I have realized that I will need to use an NSAttributedString but am not sure as to how to create the UI and format the string so I am able to save it to a database. If you could point me in a proper direction that would be greatly appreciated. Thanks!

The UI is simply an ordinary editable UITextView with allowsEditingTextAttributes set to true.
How you save is up to you, but the most universal solution is probably to pull out the UITextView's attributedText, archive it into an NSData (now known as Data in Swift), and save it off.

Related

How to fade in individual letters of text on iOS [duplicate]

This question already has answers here:
How to Make a Secret iOS App Text Animation
(4 answers)
Closed 8 years ago.
What's the best way to fade in individual letters of a UILabel over time? I'm looking to create something similar to the example below.
http://s11.postimg.org/5s16qmwn5/secret.gif
I wouldn't use UILabel to do this.
I would create a UIView with CATextLayers inside it, one text layer for each character. Then you can animate the text layers independently.
Check out apple's WWDC videos on core animation to learn how it works. It's very simple.
You may want to use NSAttributedText to create your own UITextView or UILabel that does that, basically randomly assigning UIColors with decreasing Alpha to different letters,
It will take a while to find the correct speed and rate of change. Open source it then :)

Display the iOS Emoji keyboard [duplicate]

This question already has answers here:
Change the iOS keyboard layout to emoji?
(3 answers)
Closed 9 years ago.
Can I toggle between the standard keyboard and the Emoji keyboard as the input view for a UITextView even if the user doesn't have the Emoji keyboard added as one of their keyboards in Settings?
No, you can't, I'm afraid. The Emoji keyboard is effectively a "language" setting that the user has to make and you cannot influence that.
The only thing you can change is the keyboard type.
You might want to experiment with a custom keyboard view, like PMCustomKeyboard if that feature is really important to you.
I've also found an interesting article that might help you: Customizing the iOS keyboard.

How to print the string #"123/456/789" in UIWebView? [duplicate]

This question already has answers here:
How do you remove links from UIWebView?
(2 answers)
Closed 8 years ago.
I have a long text paragraph in which there is a string similar to "123/456/789". When I tried to use UIWebView to display it, the UIWebView always insert something like there is a web link there (an extra underscore and blue color, like 123/456/789 with underscore). But I only want the normal black color just like others. Why does UIWebView add those "link" automatically? How can I avoid that?
Thanks,
Steve
Sounds like the work of a data detector. The web view can automatically detect certain kinds of data, like phone numbers, and make them tappable links. This is often nice, because it's much easier to tap a phone number to make a call than to have to remember it and dial it yourself.
You can specify which types of data the web view should detect by setting its dataDetectorTypes property.

How to make Facebook mention like highlighting word in UITextView?

HERE IS SAMPLE IMAGE -->
I'm trying to make text input feature very similar to Facebook's one. The mention that start with # will generate list of my friends name then selecting one will act as something like an object. So deleting the highlighted word will remove whole word in UITextView.
I wonder if that is part of UITextView. Does anyone know how to implement?
Thank you in advance.
I know this is a pretty old question but I've actually made libraries that assist with mentions, when to show the list, does the highlighting etc. It uses attributes on an attributed string to set background.
https://github.com/szweier/SZMentions
https://github.com/szweier/SZMentionsSwift
You'll want to have a look at NSAttributedString. While this class exists in iOS 3.2 or greater, you cannot display it in a UITextView unless you are on iOS 6 or later.

Syntax Highlightable UITextView on iOS [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
UITextView with Syntax Highlighting
I'm working on a source code editor for the iPad, but I'm stuck on square one: syntax highlighting. I'm planning on using libclang to do the heavy lifting, but there doesn't seem to be a good way to show rich text on iOS. I think the best solution would be to have a subclass of UITextView that supports NSAttributedString drawing, but I'm not sure how to do that. I've seen things like Omni's text editor, but it doesn't look very good. I only need multiple colors of a monospaced font. Is there a framework or library that would help draw attributed strings in a UITextView subclass?
Thanks in advance.
http://www.cocoanetics.com/parts/dtrichtexteditor/ is a paid solution that would do almost all the work for you.
https://github.com/Cocoanetics/DTCoreText is the open source backend for just the text highlighting.

Resources