Repository navigation
Expand file tree
/
Copy pathFSTwoViewController.m
More file actions
98 lines (56 loc) · 2.33 KB
/
Copy pathFSTwoViewController.m
File metadata and controls
98 lines (56 loc) · 2.33 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// FSTwoViewController.m
// FSTextViewDemo
//
// Created by 四维图新 on 16/3/28.
// Copyright © 2016年 四维图新. All rights reserved.
//
#import "FSTwoViewController.h"
#import "UITextView+Extension.h"
#import "FSTextView.h"
@interface FSTwoViewController ()<UITextViewDelegate>
@property (nonatomic, weak) UIView *redView;
@end
@implementation FSTwoViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO;
[self setupTextView];
}
- (void)setupTextView
{
UIView *redView = [[UIView alloc] init];
self.redView = redView;
redView.backgroundColor = [UIColor redColor];
redView.frame = CGRectMake(0, 200, self.view.bounds.size.width, 55);
[self.view addSubview:redView];
// FSTextView *textView = [[FSTextView alloc] initWithFrame:CGRectMake(50, 10, self.view.bounds.size.width - 100, 35)];
// UITextView *textView = [[UITextView alloc] init];
FSTextView *textView = [[FSTextView alloc] init];
textView.automaticallyAdjustsTextViewHeight = YES;
textView.maxHeight = @(100);
textView.delegate = self;
textView.font = [UIFont systemFontOfSize:18];
textView.placeholder = @"Fusen Placeholder Fusen";
textView.placeholderAttribute = @{NSForegroundColorAttributeName : [UIColor redColor]};
textView.delegate = self;
textView.frame = CGRectMake(50, 10, self.view.bounds.size.width - 100, 35);
textView.layer.cornerRadius = 5;
textView.layer.masksToBounds = YES;
textView.layer.borderWidth = 1;
textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
[redView addSubview:textView];
__weak typeof(self) weakSelf = self;
textView.boundsBlcok = ^(CGFloat contentHeightChangeValue, CGRect bounds, BOOL isBoundsChanged){
if (isBoundsChanged)
{
[UIView animateWithDuration:0.25 animations:^{
CGRect frame = weakSelf.redView.frame;
frame.size.height += contentHeightChangeValue;
frame.origin.y -= contentHeightChangeValue;
weakSelf.redView.frame = frame;
}];
}
};
}
@end