Reputation: 3054
I'm attempting to draw a richly laid out text view on iPhone that features:
kCTParagraphStyleSpecifierParagraphSpacing
)kCTParagraphStyleSpecifierFirstLineHeadIndent
)kCTParagraphStyleSpecifierAlignment
)I'm using OHAttributedLabel
. The first three points I achieved without much trouble by just setting some paragraph style attributes on my NSAttributedString
.
The drop cap I managed to implement by hacking OHAttributedLabel
:
CGMutablePathRef
the size of the drop cap by adding an extra CGPathAddRect
, as detailed in this excellent blog post.CTFrameDraw
call.My problem: The paragraph styles and the custom text path are incompatible. When I cut a rectangular chunk out of the main text's path, all the paragraph styles seem to get thrown away.
Does anyone know a way to make them work together? Or can anyone think of another way to implement drop caps? (Short of using a UIWebView
+ CSS, which I'd rather not have the overhead of!)
Thanks!
Upvotes: 2
Views: 798
Reputation: 4492
You can use straight Core Text to achieve this, in the following post I explain the use of 2 framesetters to lay out text with drop caps in a UIView. In the code example (there's also a link to a github repo) you'll be able to see where the paragraph styles are created and applied to the main text view.
https://stackoverflow.com/a/14639864/1218605
Upvotes: 1