diff options
Diffstat (limited to 'Juick/Views/MessageInputView.m')
-rw-r--r-- | Juick/Views/MessageInputView.m | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Juick/Views/MessageInputView.m b/Juick/Views/MessageInputView.m index c4d96de..054ded7 100644 --- a/Juick/Views/MessageInputView.m +++ b/Juick/Views/MessageInputView.m @@ -10,9 +10,23 @@ @implementation MessageInputView --(void) awakeFromNib { - [super awakeFromNib]; - [self setTintColor:[UIColor colorNamed:@"Title"]]; +- (CGSize) textSize { + CGSize size = CGSizeMake(self.textView.bounds.size.width, FLT_MAX); + return [self.textView sizeThatFits:size]; +} + +- (CGSize) intrinsicContentSize { + CGSize viewSize = [self textSize]; + viewSize.height = viewSize.height + self.bottomConstraint.constant + self.topMarginConstraint.constant; + return viewSize; +} + +- (void)textViewDidChange:(UITextView *)textView { + if ([self textSize].height != self.textHeightConstraint.constant) { + self.textHeightConstraint.constant = [self textSize].height; + [self layoutIfNeeded]; + } + [self.sendButton setEnabled:[self.textView.text length] > 0]; } - (IBAction)sendPressed:(id)sender { |