textView 基本用法 设置行间距 设置文字大小重量 文字布局
来源:互联网 发布:博奥软件 编辑:程序博客网 时间:2024/05/28 06:07
//初始化·
self.textview = [[UITextViewalloc] initWithFrame:CGRectMake(30,100, KWIDTH - 60,KWIDTH)];
//字体大小粗细
self.textview.font = [UIFont systemFontOfSize:30weight:20];
//字体颜色
self.textview.textColor = [UIColorredColor];
//是否可以编辑
self.textview.editable =YES;
//文字显示方式
self.textview.textAlignment = NSTextAlignmentRight;
//背景颜色
self.textview.backgroundColor = [UIColor whiteColor];
//文本框的颜色·和宽度;
self.textview.layer.cornerRadius = 6.0f;
self.textview.layer.borderWidth = 5.0;
self.textview.layer.borderColor = [UIColor blueColor].CGColor;
//设置是否编辑文本框的属性
self.textview.allowsEditingTextAttributes = YES;
//是否允许滚动
self.textview.scrollEnabled = YES;
//设置文字大小及文字宽度
self.textview.font = [UIFont systemFontOfSize:18.0weight:16];
//设定行距
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc] init];
paragraphStyle.lineSpacing =12; //行距
NSDictionary *attributes =@{ NSFontAttributeName:[UIFontsystemFontOfSize:18],NSParagraphStyleAttributeName:paragraphStyle};
self.textview.attributedText = [[NSAttributedString alloc]initWithString:self.textview.textattributes:attributes];
//添加到视图
[self.viewaddSubview:self.textview];
//添加代理;
self.textview.delegate =self;
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView{
NSLog(@"%s,",__FUNCTION__);
returnYES;
}
-(void)textViewDidBeginEditing:(UITextView *)textView{
NSLog(@"%s,",__FUNCTION__);
}
-(BOOL)textViewShouldEndEditing:(UITextView *)textView{
NSLog(@"%s,",__FUNCTION__);
returnYES;
}
-(void)textViewDidEndEditing:(UITextView *)textView{
NSLog(@"%s,",__FUNCTION__);
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.textviewresignFirstResponder];
}
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if ([textisEqualToString:@"\n"]) {
[textView resignFirstResponder];
returnNO;
}
NSLog(@"%s,",__FUNCTION__);
returnYES;
}
- textView 基本用法 设置行间距 设置文字大小重量 文字布局
- TextView行间距设置
- TextView设置行间距
- textView设置行间距
- 设置android textview行间距
- textView 设置行间距 行宽
- 设置TextView的行间距
- 设置textView的行间距
- android textview 行间距设置
- 设置textView的行间距
- android设置TextView行间距
- TextView设置文字大小
- Android中设置TextView的行间距
- TextView中设置行间距的方法
- Android设置TextView行间距(非行高)
- TextView中设置行间距的方法
- 设置textview lable的行间距
- Android设置TextView行间距(非行高)
- android 中对返回事件的处理
- C++中this指针的用法
- 扩展欧几里德算法详解
- (管理后台5)如何获取 AppKey 和 Secret?
- 欢迎使用CSDN-markdown编辑器
- textView 基本用法 设置行间距 设置文字大小重量 文字布局
- JavaScript cookie示例
- Android沉浸式模式的实现
- ViewPager+FragmentStatePagerAdapter 实现菜单
- Gradient Boosting Classifier sparse matrix issue using pandas and scikit
- 靛青K专访:iOS界的字幕组 -- SwiftGG 要做更多事
- popupwindow中的listview设置点击事件没响应
- 通过Hibernate框架搭建简单的dao层
- typedef用法