UITextView是UITextField的加强版,为什么?
UITextField是继承自UIView,是单行文本;UITextView是继承自ScrollView,是文本超过显示框可以滚动查看。
UITextField与UITextView的属性是差不多,这里我就展示UITextView的
一、属性的实例应用:
1、新建一个UITextView对象:
UITextView *v1 = [[UITextView alloc]new];
UITextView *v1 = [UITextView new];
2.属性的使用:
设置文本框的默认显示信息
v1.text = @"这个事UITextView视图";
设置字体大小,系统的字体大小
v1.font = [UIFont systemFontOfSize:20];
设置字体颜色
v1.textColor = [UIColor blackColor];
设置字体显示的位置,一般靠右
v1.textAlignment = NSTextAlignmentRight;
设置文本内容是可编辑的、可选取的
v1.editable = YES;
v1.selectable = YES;
设置文本框的背景颜色
v1.backgroundColor = [UIColor blueColor];
设置是否可以滑动
v1.scrollEnabled= YES;
设置外框
v1.layer.borderColor = [UIColor redColor].CGColor;
v1.layer.borderWidth = 1;
v1.layer.cornerRadius =5;
显示
[self.view addSubview:v1];