Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
786 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 Reply

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...