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.
Related
We have an embedded HTML form type editor in a macOS app that needs to be filled by the user. We are using WKWebView with Swift and it's all working fine but we are not able to get the spell check working in WKWebView. I mean it does work and corrects some words but doesn't show red dotted underline on misspelled words like WebView.
WebView shows dotted redline where WKWebView does not. Found that WebView has property as isContinuousSpellCheckingEnabled but no such property is available in WKWebView.
My simple requirement to highlight misspelled words, please help if there's anything available.
I did not found it yet: so far no such property is available in WKWebView.
From apple
Description Daniel Bates 2018-08-21 11:23:20 PDT
We should render misspelled words with the spelling correction dots in
iOS WebKit (i.e. when using WKWebView). Currently we only support this
in iOS WebKit Legacy (i.e. when using UIWebView).
After a successful migration to swift 2.3 in my application, I found a font glitch.
I have an extension for UIFont where I change system font to my custom font.
In iOS 9 and earlier everything worked as expected. In iOS 10 it doesn't.
The problem was in self.fontName. Normally it should return "fontName" + suffix for style (ex:regular, bold, etc).
However in iOS 10 for regular the style, it doesn't return suffix only "fontName".
I googled to found why but couldn't find anything.
The problem is fixed but why this happens I don't know. Any idea?
Using font names has never been a good idea.
Use fontDescriptor and inspect the UIFontDescriptor's fontAttributes and symbolicTraits to obtain information on the font in question. You can then create a new descriptor with modified attributes and/or traits, and obtain a font with that descriptor using init(descriptor:size:).
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.
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
is it possible to bring another language font in iphone sdk and to insert that font value (for example,chinese) in UILabel value? any help please?
You can include the font as a resource in the project, then load the font using CoreText but it's not trivial.
The main step is to create a CTFontDescriptor that will load the font. There is sample code in the iPhone SDK documentation that I can't quote, the name of the section I found useful is...
CoreText Listing 2-9 "Creating a font from serialized data"