Created
October 16, 2013 16:26
-
-
Save cmezak/7010710 to your computer and use it in GitHub Desktop.
Well, I tried so many things, hoping that some of the next TextKit API would finally provide a way to precalculate the needed height for a UITextView with a given width and text. Oh well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HOW THE FUCK TALL DOES MY TEXT VIEW NEED TO BE?!? | |
@interface UITextView (WhatFuckingSize) | |
+ (CGSize)sizeThatFuckingFits:(CGSize)size withAttributedText:(NSAttributedString *)attributedText textContainerInsets:(UIEdgeInsets)textContainerInsets; | |
@end | |
static UITextView *FuckingTextView; | |
@implementation UITextView (WhatFuckingSize) | |
+ (CGSize)sizeThatFuckingFits:(CGSize)size withAttributedText:(NSAttributedString *)attributedText textContainerInsets:(UIEdgeInsets)textContainerInsets | |
{ | |
UITextView *textView = [self FuckingTextView]; | |
textView.attributedText = attributedText; | |
textView.textContainerInset = textContainerInsets; | |
return [textView sizeThatFits:size]; | |
} | |
+ (UITextView *)FuckingTextView | |
{ | |
if (FuckingTextView == nil) FuckingTextView = [UITextView new]; | |
return FuckingTextView; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment