UITextView 的一些用途
2015-11-26 12:41
411 查看
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(50, 100, 275, 100)]; textView.backgroundColor = [UIColor grayColor]; NSString *str = @"编辑文本时没那么重要,但如果要18672136121 但如果要以好看易读的方式展现文本时,这就相当重要, www.baidu.com, 459880251@qq.com zhz459880251@163.com"; NSMutableParagraphStyle *paraStyle01 = [[NSMutableParagraphStyle alloc] init]; //每行结尾 英文断点 paraStyle01.hyphenationFactor = 0.3; NSDictionary *attrDict01 = @{ NSParagraphStyleAttributeName: paraStyle01, NSFontAttributeName: [UIFont systemFontOfSize: 15] }; textView.attributedText = [[NSAttributedString alloc] initWithString: str attributes: attrDict01]; textView.text = str; //设置不能编辑状态, 才能开启dataDetectorTypes 属性 textView.editable = NO; textView.dataDetectorTypes = UIDataDetectorTypeAll; textView.delegate = self; [self.view addSubview:textView]; ---------------------------------------------- // 几种常用的代理方法 //将要开始编辑 - (BOOL)textViewShouldBeginEditing:(UITextView *)textView; //将要结束编辑 - (BOOL)textViewShouldEndEditing:(UITextView *)textView; //开始编辑 - (void)textViewDidBeginEditing:(UITextView *)textView; //结束编辑 - (void)textViewDidEndEditing:(UITextView *)textView; //内容将要发生改变编辑 - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text; //内容发生改变编辑 - (void)textViewDidChange:(UITextView *)textView; //焦点发生改变 - (void)textViewDidChangeSelection:(UITextView *)textView;
相关文章推荐
- 两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对?
- 从UE3到UE4
- 详解iOS的UI开发中控制器的创建方法
- ACM学习历程—UESTC 1226 Huatuo's Medicine(数学)(2015CCPC L)
- ueditor 编辑器,自定义图片上传及图片显示
- ACM学习历程—UESTC 1215 Secrete Master Plan(矩阵旋转)(2015CCPC A)
- 73 Which two are the prerequisites to enable Flashback Data Archive? (Choose two.) A. Database must
- UITableVIew 编辑
- iOS开发日记48-详解UIPickerView
- Apue Chapter 7 习题答案
- 自定义UINavigationController 切换动画
- 进击的KFC:UI(六)UISegmentControl,UISlider,NSTimer,UIImageView
- 根据Excel单元格坐标修改单元格内的Value
- <merge/>标签在UI界面中的优化作用
- easyUI 验证控件应用、自定义、扩展验证 手机号码或电话话码格式
- easyui 表单自定义验证 正则表达式验证
- JAVA生成短8位UUID
- UIImageView 序列帧动画及内存优化详解
- 怎么让tableview的section的headerView随着cell一起滑动
- EsayUI + MVC + ADO.NET(工作单元)