UITextView使用总结
来源:互联网 发布:易幻网络待遇怎么样 编辑:程序博客网 时间:2024/06/16 17:00
iOS7中文本对齐方式有以下几种:
enum { NSTextAlignmentLeft = 0, 左对齐,默认 NSTextAlignmentCenter = 1, 居中对齐 NSTextAlignmentRight = 2, 右对齐 NSTextAlignmentJustified = 3, 在一个段落的最后一行自然对齐 NSTextAlignmentNatural = 4, 默认对齐方式 } NSTextAlignment;
// 设置自动纠错方式textView.autocorrectionType = UITextAutocorrectionTypeNo;
// 自动纠错方式有以下几种: enum { UITextAutocorrectionTypeDefault, 默认 UITextAutocorrectionTypeNo, 不自动纠错 UITextAutocorrectionTypeYes, 自动纠错 } UITextAutocorrectionType;
// 设置自动大写方式textView.autocapitalizationType = UITextAutocapitalizationTypeNone;
// 自动大写方式有以下几种: enum { UITextAutocapitalizationTypeNone, 不自动大写 UITextAutocapitalizationTypeWords, 单词首字母大写 UITextAutocapitalizationTypeSentences, 句子的首字母大写 UITextAutocapitalizationTypeAllCharacters, 所有字母都大写 } UITextAutocapitalizationType;
// 设置键盘的样式textView.keyboardType = UIKeyboardTypeDefault;
// 键盘样式有以下几种: enum { UIKeyboardTypeDefault, 默认键盘,支持所有字符 UIKeyboardTypeASCIICapable, 支持ASCII的默认键盘 UIKeyboardTypeNumbersAndPunctuation, 标准电话键盘,支持+*#字符 UIKeyboardTypeURL, 只支持URL字符的URL键盘,支持.com按钮 UIKeyboardTypeNumberPad, 数字键盘 UIKeyboardTypePhonePad, 电话键盘 UIKeyboardTypeNamePhonePad, 支持输入人名的电话键盘 UIKeyboardTypeEmailAddress, 电子邮件键盘 UIKeyboardTypeDecimalPad, 有数字和小数点的数字键盘 UIKeyboardTypeTwitter, 优化的键盘,方便输入@、#字符 UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, } UIKeyboardType;
// 设置return键样式textView.returnKeyType = UIReturnKeyDefault;// return键有以下几种样式: enum { UIReturnKeyDefault, 默认,灰色按钮,标有Return UIReturnKeyGo, 标有Go的蓝色按钮 UIReturnKeyGoogle, 标有Google的蓝色按钮,用于搜索 UIReturnKeyJoin, 标有Join的蓝色按钮 UIReturnKeyNext, 标有Next的蓝色按钮 UIReturnKeyRoute, 标有Route的蓝色按钮 UIReturnKeySearch, 标有Search的蓝色按钮 UIReturnKeySend, 标有Send的蓝色按钮 UIReturnKeyYahoo, 标有Yahoo的蓝色按钮 UIReturnKeyYahoo, 标有Yahoo的蓝色按钮 UIReturnKeyEmergencyCall, 紧急呼叫按钮 } UIReturnKeyType;
// 设置是否可以拖动textView.scrollEnabled = YES;// 设置代理textView.delegate = self;// 自定义文本框placeholdertip = [[UILabel alloc] initWithFrame:CGRectMake(16, 14, 320, 25)];tip.text = @"您的意见是我们前进的最大动力,谢谢!";tip.font = [UIFont fontWithName:@"Arial" size:16.5f];tip.backgroundColor = [UIColor clearColor];tip.enabled = NO;// 自定义文本框字数统计count = [[UILabel alloc] initWithFrame:CGRectMake(270, 170, 35, 20)];count.text = @"240";count.textAlignment = NSTextAlignmentRight;count.font = [UIFont fontWithName:@"Arial" size:15.0f];count.backgroundColor = [UIColor clearColor];count.enabled = NO;// 显示文本框及相关控件[self.view addSubview:feedback];[self.view addSubview:tip];[self.view addSubview:count];// 限制输入文本长度- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if (range.location < 240) { return YES; } else { return NO; }}// 自定义文本框placeholder- (void)textViewDidChange:(UITextView *)textView{ count.text = [NSString stringWithFormat:@"%d", 240 - feedback.text.length]; if (textView.text.length == 0) { tip.text = @""; } else { tip.text = @""; }}原文地址:http://www.itechzero.com/ios-development-series-four-uitextview-usage-summary.html
0 0
- UITextView使用总结
- UITextView 使用
- UITextView使用
- UITextView 使用
- UITextView用法总结
- UITextView用法总结
- 使用UITextView的问题及自定义UITextView
- UITextView使用技巧(一)
- UITextView使用技巧(二)
- UITextView使用笔记
- UItextView和UItextfiled 使用
- UITextView的使用详解
- UITextView的使用详解
- UITextView 的使用
- UITextView的使用记录
- UITextView的使用详解
- UITextView的使用详解
- UITextView的使用详解
- Github使用gitignore忽略增加指定文件
- font-awesome
- 测试用例的初始化和结束函数
- js的input框限制输入内容
- SCF架构开发:Maven+weblogic+eclipse开发总结
- UITextView使用总结
- markdown转为html及pdf
- spring源码解析-Ioc1
- 考虑实现Comparable接口
- Oracle存储过程详解
- 4.7编写一个函数,从一个字符串中去除多余的空格。
- 如何优化程序员的内部培训
- DOM、JDOM、DOM4J的区别
- 人类视觉感知【4】立体图像的质量评价