最近使用UITextField 和 UITextView 。对于其相关内容进行了一些总结,主要方便自己以后的使用
UITextView:
能输入多行,可以滚动显示浏览全文,不可以设置提醒文字(没有placeholder属性),无占位,继承自UIScrollView。
UITextView的常规方法
//初始化UITextView
UITextView *textview = [[UITextView alloc] initWithFrame:CGRectMake(100, 100, 300, 44)];
//设置背景颜色
textview.backgroundColor=[UIColor blueColor];
//设置当文字超过视图的边框时是否允许滑动,默认为“YES”
textview.scrollEnabled = NO;
//设置是否允许编辑内容,默认为“YES”
textview.editable = YES;
//设置代理方法的实现类
textview.delegate = self;
//设置字体名字和字体大小;
textview.font=[UIFont fontWithName:@"Arial" size:18.0];
// 设置显示文字颜色
textview.textColor = [UIColor blackColor];
//设置自动大写的方式
textView.autocapitalizationType = UITextAutocapitalizationTypeNone;
// 自动大写方式有以下几种:
enum {
UITextAutocapitalizationTypeNone, //不自动大写
UITextAutocapitalizationTypeWords, //单词首字母大写
UITextAutocapitalizationTypeSentences, //句子的首字母大写
UITextAutocapitalizationTypeAllCharacters, //所有字母都大写
} UITextAutocapitalizationType;
//设置键盘类型一般为默认
textview.keyboardType = UIKeyboardTypeDefault;
typedef enum {
UIKeyboardTypeDefault, //默认键盘,