Is there any way to display colorful text in iPhone without using UIWebView
Eg "red blue green voilet"
all in single UITextView, UITextField, UILabel or anything except UIWebview.
Is it possible at all?
Yes, you can use a NSAttributed string and then supply that to a CATextLayer or an open source library like AliSoftware's OHAttributedLabel.
Here's a related question that may help you out.
Related
I'm looking at an NSMutableAttributedString example by apple : http://developer.apple.com/library/ios/#samplecode/CoreTextPageViewer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010699-Intro-DontLinkElementID_2 and see that they load attributed strings as XML files.
Are there any examples of how to use a text editor create an attributed string on an iPhone/iPad? I don't want to create attributed string programmatically, but want the user to be able to create an attributed string using a text editor.
Is this kind of work possible?
Mixing three or four answers I have read on this forum, you can do this:
Create your own user interface buttons for underline, add color... (I suggest on storyboard, but this is your election)
Subclass UITextView and override the drawRect method for display, using CoreText, because you'll need an editable text view. Here you have how to do it.
Create a method for change the attributes to each letter user writes after touching, p.e., the "underline" button.
I hope it helps you!!
I would like to show list of emotion icons / smiley icons when tap of a button. on selecting any, i want that icon to placed on my uitextview.
Is there any options to do with iPhone app , if not will it require more time to get it
Please let me know and thanks
NSAttributedString is a option to archive your goal.
There is a project you may have a look:
emotionlabel
It's based on DTCoreText project which enables you drawing simple rich text like any HTML document without having to use a UIWebView.
Take one UIImage that looks like UITextField and set it on the UILabel background image. Once the emoticon is selected, put it on the UILabel. Hope that would help you.
In my app, I have modified the UILabel and made it underline the text if the phone number or email appears.
but I want to highlight the text when the phone number or email is touched as shown below (I want something like what has been shown below by the dark gray highlight in background of the text "http://www.foodreporter.net".
I want to do this without use of CoreText as my app targets from iOS 3.1.2 onwards. So I don't want to use the CoreText and Attributed strings.
I want to subclass the UILabel and do it somehow. How can it be done?
I don't have the option to use OHAttributedLabel and TTTAttributedLabel.
I suggest for a workaround. What you can do is, use custom UIButton instead of label. Set the default and highlighted image of the button according to your need.(Simple text for default, and highlighted text for highlighted).
Happy Programming
How can you create a UITextView that can have images inline? I looked up NSAttributedString, but it seems iOS does not support image attachments. Any ideas for an editable text view that can display images (I suppose RTF would do this)?
Thanks in advance for your help!
The only method I am aware of is to use a UIWebView. There is no way to add images to a UITextView, unfortunately, just plain text.
You could use the NSTextAttachment class. It lets you insert images inline of text.
I found an example of this in a cool project here: https://github.com/dzog/ImgGlyph. ImgGlyph provides UITextView and UILabel subclass implementations that help you replace specific strings with images and ensures they're sized correctly with respect to the text surrounding it.
Is it possible to underline or embolden certain bits of text in a UITextView?
For example my Text View has headings in it, and would like those underlined...
Random Mode
In random mode, you can generate numbers...
Sweepstake Mode
In sweepstake mode...
If not, what is the best way to achieve this?
Thanks
Use should use NSAttributedString, and use controllers for drawing NSAttributesString.
Controller for NSAttributedString
Note: you can't use UITextView to display a NSAttributedString
Update
From iOS6, UILabel now support NSAttributedString, you should use UILabel directly instead of OHAttributedLabel as it is now natively supported by the OS.
I believe NSAttributedString is what you're after, it's available in iOS 3.2 or later: look at this question
I know this is an old thread, but this is something I just discovered myself. At least in Xcode version 4.6.3 this is possible by using an attributed textView. What's even better is that it's possible to all be done in Interface Builder!
Here are the steps:
Place your textView at the desired location
Select the textView and open up the Attributes tab under the Utilities panel
Change the textView text to "attributed"
Enter your desired text
Now, highlight whatever text you want bolded, underlined, etc.
Click on the "T" button next to the fontName
In the popup, select your desired typeface (ex: Bold)
You should see the desired typeface displayed in the Utilities panel
Enjoy!