Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
782 views
in Technique[技术] by (71.8m points)

iphone - How to create a UILabel or UITextView with bold and normal text in it?

I am trying to create a UILabel or UITextView with bold and normal text inside.

I have gone through the attributedstring but when I am setting this in label of my custom cell it doesn't display any text.

I have also used the UITextView setContentToHTMLString: method, but it is undocumented and app get rejected.

Can anyone give some sort of solution to this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Up until iOS 6.0, you couldn't do this with a normal UILabel or UITextView, but you can use NSAttributedString objects with a few possible open source solutions.

Like TTAttributedLabel or OHAttributedLabel.

One solution built into the iOS SDK, you could also use a CATextLayer which has a string property that can be set to a NSAttributedString.

And, like the commenters below say, yes you can do this with the "attributedText" property. Horray! (for Apple listening to developer's very often repeated feature requests)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...