Skip to content

Instantly share code, notes, and snippets.

@stuartjmoore
stuartjmoore / WPHangingQuoteViewController.m
Last active June 15, 2022 07:29
Hanging quotes on iOS 7.Basically, we set the UITextView's left inset to the negative width of a double quote, then undo that per line fragment if the line doesn't start with a double quote.And the opposite for an exclusion path lines.
- (void)loadOrResizeOrSometing {
/*
* After creating the text view or resizing the font, set the quoteWidth and contentInset.
*/
WPTextContainer *textContainer = (WPTextContainer*)paragraphView.textContainer;
textContainer.spaceWidth = [self widthForCharacter:@" "];
textContainer.charWidths = @{
@(8220) : @([self widthForCharacter:@"“"]),
@(8216) : @([self widthForCharacter:@"‘"]),
@('"') : @([self widthForCharacter:@"\""]),