blob: 054ded76ce9aa5d31364451d16b056d6b226125d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
//
// MessageInputView.m
// Juick
//
// Created by Vitaly Takmazov on 08/04/2018.
// Copyright © 2018 com.juick. All rights reserved.
//
#import "MessageInputView.h"
@implementation MessageInputView
- (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 {
[self.delegate textSent:self.textView.text];
self.textView.text = nil;
}
@end
|