I want to draw an NSAttributedString in a rect, just like I would do with a normal string: [normalString drawInRect:rect]; but I can’t figure out how. I don’t want any UILabel subclasses since I’m implementing a fast scrolling UITableView with no views, so it needs to be drawn. The documentation shows that drawing is only available on Mac.
Is drawing an NSAttributedString not possible on iOS?
You have to use Core Text to draw attributed strings on iOS.
The basic procedure would be to create a
CTFramesetterfrom the string and a rectangularCGPath(or any other shape you may want), then create the frame usingCTFramesetterCreateFrameand draw it withCTFrameDraw.