UIKit之UITextView

#import "TestController.h"

@interface TestController ()
@property(strong, nonatomic)UITextView *textView;
@end

@implementation TestController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}


#pragma mark - lazyload
- (UITextView *)textView{
    if (!_textView) {
        _textView = [[UITextView alloc]initWithFrame:CGRectMake(20, 20, 335, 200)];
        _textView.backgroundColor = [UIColor cyanColor];
        [self.view addSubview: _textView];
        // 文字内容
        _textView.text = @"若你不再是个孩子,就要勇敢的面对";
        // 文字颜色
        _textView.textColor = [UIColor redColor];
        // 字体
        _textView.font = [UIFont systemFontOfSize:30];
        // 键盘类型
        _textView.keyboardType = UIKeyboardTypeDefault;
        // 键盘右下角确定按钮的类型
        _textView.returnKeyType = UIReturnKeyDone;
        
        // 是否可以拖动
        _textView.scrollEnabled = YES;
        // 自适应高度
        _textView.autoresizesSubviews = UIViewAutoresizingFlexibleHeight;
         
    }
    return _textView;
}

@end

你可能感兴趣的:(UIKit之UITextView)