UITextView
来源:互联网 发布:淘宝脐橙店招图片大全 编辑:程序博客网 时间:2024/06/06 03:10
//将文本视图附加到一个已有的试图对象上-(void)loadView{ [super loadView]; CGRect viewRect = CGRectMake(0, 100, 320, 200); UITextView *textView = [[UITextView alloc] initWithFrame:viewRect]; //颜色 UIColor *myColorHue = [UIColorcolorWithHue:120.0/360.0saturation:0.75brightness:0.50alpha:1.0]; // UIColor *myColorRGB = [UIColor colorWithRed:0.75 green:1.0 blue:0.75 alpha:1.0]; // UIColor *myWhiteTransparentColor = [UIColor colorWithWhite:1.0 alpha:0.50]; // UIColor *myColor = [UIColor redColor]; textView.textColor = myColorHue; //字体与大小 UIFont *myFixed = [UIFont fontWithName:@"Courier New" size:10.0]; // UIFont *mySystemFont = [UIFont systemFontOfSize:12.0]; // UIFont *myBoldSystemFont = [UIFont boldSystemFontOfSize:12.0]; // UIFont *myItalicSystemFont = [UIFont italicSystemFontOfSize:12.0]; textView.font = myFixed; textView.editable = NO; //设置为不可编辑,默认的为可编辑 //赋予内容 textView.text = @"hello .bit hold "; //分别为左中右对齐 textView.textAlignment = UITextAlignmentLeft; // textView.textAlignment = UITextAlignmentCenter; // textView.textAlignment = UITextAlignmentRight; //直接赋值 int nBottles = 100; NSString *myFormattedString = [[NSString alloc]initWithFormat:@"%d bottles of beer on the wall",nBottles]; textView.text = myFormattedString; //读取文件 // NSString *myFile = [NSHomeDirectory() stringByAppendingPathComponent:@"Document/file.txt"]; // NSString *myFileString = [NSString stringWithContentsOfFile:myFile encoding:nil error:nil]; // textView.text = myFileString; //键盘属性 textView.keyboardType = UIKeyboardTypePhonePad; //键盘风格,8种 textView.keyboardAppearance = UIKeyboardAppearanceAlert; //键盘外观,两种:浅灰色或深灰色 textView.returnKeyType = UIReturnKeyGo; //回车键的风格 11种 textView.autocapitalizationType = UITextAutocapitalizationTypeNone;//自动大写功能 4种 textView.autocorrectionType = UITextAutocorrectionTypeDefault; //自动更正 textView.secureTextEntry = YES; //安全文本输入,即输入后会显示*号 [self.view addSubview:textView];}
UITextView协议:
//点击开始编辑:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView;
- (void)textViewDidBeginEditing:(UITextView *)textView;
//结束编辑
- (BOOL)textViewShouldEndEditing:(UITextView *)textView;
- (void)textViewDidEndEditing:(UITextView *)textView;
//更改内容
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
- (void)textViewDidChange:(UITextView *)textView;
- (void)textViewDidChangeSelection:(UITextView *)textView;
0 0
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- UITextView
- SQL - 脚本Tips
- Eclipse中web项目部署至Tomcat步骤
- web app 开发之图片压缩
- nginx url分发 特别说明
- PL/SQL DEVELOPER 使用的一些技巧
- UITextView
- 值得推荐的C/C++框架和库
- When and how to use a ThreadLocal
- 网页浏览毫秒必争,超强前端网页性能总结
- 第17章 小结
- 计算机底层知识拾遗(七)页缓存数据同步和页回收机制
- 东方通国产化基础软件——互联网文件传输平台软件TongWTP,求客户、求伙伴、求渠道,合作共赢!
- windows Azure 云使用(1)------网站服务
- MySQL安全配置向导mysql_secure_installation详解