iOS 基本控件之UITextView的基本用法

// 设置它显示的内容

_textView.text = @"Now is the time for all good developers to come to serve their country.\n\nNow is the time for all good developers to come to serve their country."; 


// 设置字体名字和字体大小

_textView.font = [UIFont fontWithName:@"Arial" size:18.0]; 


// 设置textview里面的字体颜色

_textView.textColor = [UIColor blackColor]; 


// textView中的文本排列,默认靠左

_textView.textAlignment = NSTextAlignmentCenter; 


// 设置浅灰色的背景色,默认为白色

_textView.backgroundColor = [UIColor grayColor]; 

// 设置代理

_textView.delegate = self; 

 // textView是否可被输入,默认为YES

_textView.editable = NO;

// 可以方便将文本插入到UITextView中。

_textView.attributedText = [[NSAttributedString alloc]initWithString:@"attributedText__-abc"]; 

// 弹出视图,默认为键盘

_textView.inputView = [[UIDatePicker alloc]init]; 

// 弹出视图上方的辅助视图

_textView.inputAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

// clearsOnInsertion,默认为NO,清除之前输入的文本

_textView.clearsOnInsertion = YES; 

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一.UIView属性 1.alpha 设置视图的透明度.默认为1. //完全透明 view.alpha=0; //...
    奋斗ing0310阅读 2,088评论 0 2
  • { 11、核心动画 需要签协议,但是系统帮签好 一、CABasicAnimation 1、创建基础动画对象 CAB...
    CYC666阅读 1,604评论 2 4
  • 一、简介 <<UITextView(文本视图) : UITextView可以输入多行文字并且可以滚动显示浏览全文的...
    无邪8阅读 8,384评论 6 1
  • 父类 继承于UIScrollView,所以它具有UIScrollView的属性和方法。 继承于UIScrollVi...
    炸街程序猿阅读 1,867评论 0 2
  • 今天,我们进行了思政课期中考试。 老师说,作为一名积极向上的大学生,我们必须表现出我们的朝气,于是乎,我们的考试就...
    小犟阅读 263评论 0 0