- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = NORMAL_BKG_GREY;
self.navigationController.navigationBar.translucent = NO;
//上面背景
UIView *shangView = [UIView new];
[self.view addSubview:shangView];
[shangView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(43);
make.left.mas_equalTo(self.view);
make.right.mas_equalTo(self.view);
make.height.mas_equalTo(43);
}];
shangView.backgroundColor = [UIColor whiteColor];
//题目输入
self.titleTextView = [UITextView new];
[shangView addSubview:self.titleTextView];
[self.titleTextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(shangView.mas_top);
make.left.mas_equalTo(TEXT_LINE_DISTANCE);
make.right.mas_equalTo(-TEXT_LINE_DISTANCE);
make.height.mas_equalTo(43);
}];
//解决当UITextView高度小于100时候光标晃动关键代码
self.automaticallyAdjustsScrollViewInsets = NO;
self.titleTextView.textAlignment = NSTextAlignmentLeft;
self.titleTextView.font = MIDDLE_FONT;
self.titleTextView.backgroundColor = [UIColor clearColor];
}

本文介绍如何在 iOS 应用中使用 Auto Layout 对 UITextView 进行自定义布局,并解决了 UITextView 在高度小于100时光标晃动的问题。
2156

被折叠的 条评论
为什么被折叠?



