iOS关于UITextView的基本用法属性和协议

- ( void )UI{
    //UITextView(使用须遵守UITextViewDelegate协议)
     UITextView *textView = [ UITextView new ];
     //设置是否可以编辑
     textView.editable = YES ;
     
     //设置代理
     textView.delegate = self ;
     
     //设置内容
     textView.text = @ "xxxxxxxxxx" ;
     
     //字体颜色
     textView.textColor = [ UIColor cyanColor];
     
     //设置字体
     textView.font = [ UIFont systemFontOfSize:30];
     
     //设置是否可以滚动
     //UITextView继承于UIScrollView
     textView.scrollEnabled = NO ;
     
     //UITextView 下得键盘中return 表示换行
     [ self .view addSubview:textView];
     
     //消除影响(iOS7 如果把UIscrollView 加在导航中一般内容会向下走64)
     self .automaticallyAdjustsScrollViewInsets = NO ;
}
#pragma mark - UITextViewDelegate协议中的方法
//将要进入编辑模式
- ( BOOL )textViewShouldBeginEditing:( UITextView *)textView{ return YES ;}
//已经进入编辑模式
- ( void )textViewDidBeginEditing:( UITextView *)textView{}
//将要结束/退出编辑模式
- ( BOOL )textViewShouldEndEditing:( UITextView *)textView{ return YES ;}
//已经结束/退出编辑模式
- ( void )textViewDidEndEditing:( UITextView *)textView{}
//当textView的内容发生改变的时候调用
- ( void )textViewDidChange:( UITextView *)textView{}
//选中textView 或者输入内容的时候调用
- ( void )textViewDidChangeSelection:( UITextView *)textView{}
//从键盘上将要输入到textView 的时候调用
//rangge  光标的位置
//text  将要输入的内容
//返回YES 可以输入到textView中  NO不能
- ( BOOL )textView:( UITextView *)textView shouldChangeTextInRange:( NSRange )range replacementText:( NSString *)text{ return YES ;}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值