iOS--textview
来源:互联网 发布:淘宝松下军用笔记本 编辑:程序博客网 时间:2024/05/22 02:17
1.创建并初始化
创建UITextView的文件,并在.h文件中写入如下代码:
- #import <UIKit/UIKit.h>
- @interface TextViewController : UIViewController <UITextViewDelegate>
- {
- UITextView *textView;
- }
- @property (nonatomic, strong) UITextView *textView;
- @end
在.m文件中初始化这个textview,写入代码如下:
- self.textView = [[[UITextView alloc] initWithFrame:self.view.frame]autorelease]; //初始化大小并自动释放
- self.textView.textColor = [UIColor blackColor];//设置textview里面的字体颜色
- self.textView.font = [UIFont fontWithName:@"Arial" size:18.0];//设置字体名字和字体大小
- self.textView.delegate = self;//设置它的委托方法
- self.textView.backgroundColor = [UIColor whiteColor];//设置它的背景颜色
- self.textView.text = @"Now is the time for all good developers tocome to serve their country.\n\nNow is the time for all good developers to cometo serve their country.";//设置它显示的内容
- self.textView.returnKeyType = UIReturnKeyDefault;//返回键的类型
- self.textView.keyboardType = UIKeyboardTypeDefault;//键盘类型
- self.textView.scrollEnabled = YES;//是否可以拖动
- self.textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度
- [self.view addSubview: self.textView];//加入到整个页面中
- [self.view addSubview: self.textView];//加入到整个页面中
textView.alpha = 1;
textView.backgroundColor = [UIColor blackColor];
textView.editable =NO;
textView.textAlignment = UITextAlignmentCenter;
textView.textColor = [UIColor whiteColor];
textView.font = [UIFont fontWithName:@"Marker Felt" size:30];
textView.text = @"从前sfsfdsfdsaaaaaaaaaaaaaaaaaaaaayufguighjgfuygggiugjkvgftvuytdcvtboybnbyubuvtyftyuruygyguyfytvtbiyiuuybtvc6r78vt7tb98yyfv67r6bt78v6r7cdeseerdftuyfgiyfyucghcchcghcghccgcghcghgyuuigyy89tr67r67xfcghhvjguugiuifuytftfyfuguiutfuftfyugiguiuifyufufyuyfgui";
textView.contentOffset = CGPointMake(0, -100);
textView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
textView.clipsToBounds = YES;
textView.scrollEnabled = YES;
[textView setCanCancelContentTouches:NO];
textView.showsHorizontalScrollIndicator = NO;
textView.showsVerticalScrollIndicator = NO;
textView.backgroundColor = [UIColor blackColor];
textView.editable =NO;
textView.textAlignment = UITextAlignmentCenter;
textView.textColor = [UIColor whiteColor];
textView.font = [UIFont fontWithName:@"Marker Felt" size:30];
textView.text = @"从前sfsfdsfdsaaaaaaaaaaaaaaaaaaaaayufguighjgfuygggiugjkvgftvuytdcvtboybnbyubuvtyftyuruygyguyfytvtbiyiuuybtvc6r78vt7tb98yyfv67r6bt78v6r7cdeseerdftuyfgiyfyucghcchcghcghccgcghcghgyuuigyy89tr67r67xfcghhvjguugiuifuytftfyfuguiutfuftfyugiguiuifyufufyuyfgui";
textView.contentOffset = CGPointMake(0, -100);
textView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
textView.clipsToBounds = YES;
textView.scrollEnabled = YES;
[textView setCanCancelContentTouches:NO];
textView.showsHorizontalScrollIndicator = NO;
textView.showsVerticalScrollIndicator = NO;
http://blog.csdn.net/qq_31810357/article/details/49254969
0 0
- iOS textview
- iOS--textview
- iOS textView
- IOS TextView 自适应高度
- 关于iOS中的textView
- iOS textView placeholder
- iOS textView 高度自适应
- iOS textView的使用总结
- ios textview光标往下偏移
- ios开发笔记之TextView
- ios textView 字数完美限制
- iOS TextView自适应文字高度
- iOS textview的基础用法
- iOS textView的使用总结
- iOS textView的使用总结
- iOS设置textView的placeholder
- iOS textview滚动到底部
- ios开发笔记之TextView
- 猴爬楼梯
- AC一年了
- 哈夫曼树
- Swift学习笔记21——错误处理(Error Handling)
- 经典C语言位域结构体内存对齐
- iOS--textview
- 决策树
- MD5相关
- 【bzoj4146】 [AMPPZ2014]Divisors
- 把String字符串转换为Int数组
- Windows是如何管理内存的
- Ligthoj 1407 Explosion
- 调试器
- UVA 1632题解