//本文采用的代码量比较少的一种写法,测试中未出现bug
#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()
@property (nonatomic, strong) UITextView *textView;
@end
@implementation ViewController
- (void)viewDidLoad {
[self.view addSubview:self.textView];
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view).offset(100);
make.height.equalTo(@48);
make.right.equalTo(self.inputView).offset(-20);
make.left.equalTo(self.inputView).offset(20);
}];
}
-(UITextView *)textView{
if (!_textView) {
_textView = [[UITextView alloc] init];
_textView.font = [UIFont systemFontOfSize:14];
_textView.textColor = MIN_BLACKTITLE_COLOR;
UILabel *placeHolderLabel = [[UILabel alloc] init];
placeHolderLabel.text = @"请输入您的评论";
placeHolderLabel.textColor = [UIColor lightGrayColor];
placeHolderLabel.font = [UIFont systemFontOfSize:14];
[placeHolderLabel sizeToFit];
[_textView addSubview:placeHolderLabel];
[_textView setValue:placeHolderLabel forKey:@"_placeholderLabel"];
}
return _textView;
}
@end
网友评论