Last active
December 28, 2015 15:19
-
-
Save tiagobbraga/7520992 to your computer and use it in GitHub Desktop.
UITextView com altura 'Auto' ou '100%'Códigos originais em: http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content
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
| // Para funcionar no iOS6 | |
| textview.scrollEnabled = NO; |
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
| - (void)textViewDidChange:(UITextView *)textView | |
| { | |
| CGFloat fixedWidth = textView.frame.size.width; | |
| CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)]; | |
| CGRect newFrame = textView.frame; | |
| newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height); | |
| textView.frame = newFrame; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment