开发者

How can I render different paragraph styles in Core Text?

I'm having a difficult time trying to work out how to build a page using Core Text, where I have multiple paragraphs which follow one another, but in different styles.

In other words, I would like to have a title paragraph, followed by a subtitle paragraph, followed by several body paragraphs. In HTML terms, this would be:

<h1>Some title</h1>
<h2>Some subtitle</h2>
<p>Blah blah...
         ...</p>

I have got as far as crea开发者_运维问答ting a CTFramesetter for the title, creating a CTFrame from that, and then drawing it to the context. However I don't understand how to create a new frame which flows on from the previous paragraph. Can anyone help please? Or is there some good online tutorial to help?

Thanks!

:-Joe


The easiest way to do this is to just style your NSAttributedString with the different styles before you create any framesetters.


You might want to look at this Open Source project: https://github.com/Cocoanetics/NSAttributedString-Additions-for-HTML/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜