TypeKit vs NSAttributedString - can I use TextKit as a replacement for NSAttributedString when creating styled labels?

StackOverflow https://stackoverflow.com/questions/19554903

質問

I want to style a label. Nothing crazy, just some coloring, changing of font-sizes for specific words, etc. I can do this with NSAttributedString, but would it be possible/better to do in TextKit, newly introduced with iOS 7?

I've looked around, but TextKit doesn't yet have a ton of tutorials, and none seem to address this.

役に立ちましたか?

解決

It should still be done with NSAttributedStrings as the parameters you've listed exactly describe the attributes of strings. NSTextStorage is a subclass of NSMutableAttributedString but it's not intended for what you want to do (I think this class might have misled you).

Using Text Kit to Draw and Manage Text contains a nice overview of Text Kit objects, I highly recommend reading it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top