I have a random string given below.
ungs- und AnimationsprogrammSport /
Unterhaltung: Gegen Ge
I would like to display the Sport text as a bold.
ungs- und Animationsprogramm
Sport / Unterhaltung: Gegen G
How should can I display text like this?
Thanx in advanced
iOS does not yet support the display of attributed text.
I suggest using Three20's style component.
Look at CoreText and NSAttributedString in iOS4.
As a starting point, consider reviewing the WWDC videos on text handling...
Related
I have an app that retrieves a user's stream and puts it into a UITableView. However, some include emojis (those little smile faces in iOS), and they just return as boxes in my UILabel.
I've done some research, and I still can't figure it out. Does the text type need to be changed?
Thanks!
Please explain your problem better,from the piece that i understood,notice that emojis have native support in iPhone,so any app can display an emoji in a text box,i recommend you to check the methods you're using to add text to the uitableview and the text encoding from the string which is being displayed,also you could check this link
use NSString drawinrect to display emoji instead of drawGlyphsForGlyphRange.
I'm pulling in tweets for my application and I want to be able to format my tweets in a certain way and color. For example, here would be a simple tweet...
"#somename This is a sample tweet from twitter. - 7 hours ago"
Is it possible to take the last part of the string, in this case the "7 hours ago" and change the font / font color?
I'm using stringWithFormat: in order to format in this way:
tweet = [NSString stringWithFormat:#"%#%#", title, time];
But I am unsure if I am able to change the time font and color using this code.
Anyone done this before?
Edit
I've attempted this using AliSoftware's OHAttributedLabel, but I am using ARC and this doesn't seam to be working for me.
Is there a standard "iOS" way of accomplishing this? Maybe using NSAttributedString possibly?
You could use Core Text. Maybe the following question would help you Is it possible to set different font in One UIlabel?
You have to import CoreText.framework in your App
NSStrings don't know about fonts. Have a look at NSAttributedString and Core Text. References:
Text, Web, and Editing Programming Guide for iOS
NSAttributedString Class Reference
UILabel with two different color text
iPhone - UILabel containing text with multiple fonts at the same time
The font/font color are not inherent attributes of the data type NSString. You could use two separate UILabels, or create a small UIWebView to format the text.
Is there a way to directly use HTML tags in iPhone SDK? I was wondering how could I display the following text using HTML in a UILabel :
My name is Nitish and I am 24 years old.
It does not seem to be allowed. Look at following post as well:
iPhone - UILabel containing text with multiple fonts at the same time
Look at this alternative as well:
iPhone - UILabel containing text with multiple fonts at the same time (another asnwer)
You can't use UILabel to display richtext, you will have to move to CoreText.
https://github.com/Cocoanetics/NSAttributedString-Additions-for-HTML will allow you to create NASttributeString from HTML source.
This library might help.
https://github.com/elijahdou/RTLabel
Simple rich text display for iOS using html-like markups
I am having a string message i need first word of that as bold font and rest normal.
Making different label can be create problems,(need to find the size of first the make other and then make other,text is in 4 line).
How can i use NSAttributedString here. I could found How do you use NSAttributedString?
but using this shows undeclared NSForegrou... (present in app kit framework).But could not found app kit framework on sdk 4.2
Need help for making such kind of string(bold + normal text).
Go through the below blog tutorial with code, they have different font with NSAttributedString.
http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
https://github.com/Cocoanetics/NSAttributedString-Additions-for-HTML
https://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniUI/iPad/Examples/TextEditor
May I point you to the CoreText Framework and Befriending Core Text on cocoanetics.com. This will show you how to format text.
I have a text which looks like the following,
the url of the page is http://www.myurl.com, and the phone # is (999)999-9999, blah blah blah...
And I want to show it in a way such that the URL and the phone # are both in different color and bolded. Can I do it using just one UILabel control, or I need to parse them out and put them onto separate UILabel controls. (Note that the text itself could span multiple lines.) How can I do it?
Sorry I forgot to mention that this is for iPhone (CoCoa Touch), where the NSAttributedString is not available.
You might want to check out TTTAttributedLabel. It supports automatic data detection for things like Phone Numbers and URLs, as well as mixed styles with NSAttributedStrings.
You could use an NSAttributeString to decorate your string. There is a good explanation of how to use them here Change the background color of a substring of a drawn NSString?
You could try using a UIWebView, which detects both URLs and phone numbers.