- (void)setContentView{

self.contentTextView = [[UITextView alloc]initWithFrame:CGRectMake(11, 70, ScreenWidth-22, ScreenHeight-70)];

self.contentTextView.backgroundColor = [UIColor whiteColor];

self.contentTextView.delegate = self;

self.contentTextView.font = FONT_LB(15.0);

//    self.contentTextView.text = self.item.content;

[self.view addSubview:self.contentTextView];

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];

paragraphStyle.lineSpacing = 6;// 字体的行间距

paragraphStyle.alignment = NSTextAlignmentJustified;// 左右对齐

paragraphStyle.firstLineHeadIndent = 15.0f;//首行缩进

paragraphStyle.paragraphSpacingBefore = 1.0f;//段首行空白空间/

paragraphStyle.alignment = NSTextAlignmentJustified;//(两端对齐的)文本对齐方式:(左,中,右,两端对齐,自然)

paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;//结尾部分的内容以……方式省略 ( "...wxyz" ,"abcd..." ,"ab...yz")

paragraphStyle.headIndent = 20;//整体缩进(首行除外)

paragraphStyle.tailIndent = 20;//

paragraphStyle.minimumLineHeight = 10;//最低行高

paragraphStyle.maximumLineHeight = 20;//最大行高

paragraphStyle.paragraphSpacing = 15;//段与段之间的间距

paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;//从左到右的书写方向(一共➡️三种)

paragraphStyle.lineHeightMultiple = 15;/* Natural line height is multiplied by this factor (if positive) before being constrained by minimum and maximum line height. */

paragraphStyle.hyphenationFactor = 1;//连字属性 在iOS,唯一支持的值分别为0和1

NSDictionary *attributes = @{

NSFontAttributeName:[UIFont systemFontOfSize:15],

NSForegroundColorAttributeName:LableTextColor333,

NSParagraphStyleAttributeName:paragraphStyle

};

self.contentTextView.attributedText = [[NSAttributedString alloc] initWithString:self.item.content attributes:attributes];

//定义一个toolBar

UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 35)];

topView.backgroundColor = [UIColor whiteColor];

//设置style

[topView setBarStyle:UIBarStyleDefault];

//定义两个flexibleSpace的button,放在toolBar上,这样完成按钮就会在最右边

UIBarButtonItem * button1 =[[UIBarButtonItem  alloc]initWithBarButtonSystemItem:                                        UIBarButtonSystemItemFlexibleSpace target:self action:nil];

UIBarButtonItem * button2 = [[UIBarButtonItem  alloc]initWithBarButtonSystemItem:                                        UIBarButtonSystemItemFlexibleSpace target:self action:nil];

//定义完成按钮

UIBarButtonItem * doneButton = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDone  target:self action:@selector(resignKeyboard)];

//在toolBar上加上这些按钮

NSArray * buttonsArray = [NSArray arrayWithObjects:button1,button2,doneButton,nil];

[topView setItems:buttonsArray];

[self.contentTextView setInputAccessoryView:topView];

}

textview 弹出键盘上面添加完成按钮,并设置输入内容的格式。的更多相关文章

  1. IOS开发之自定义系统弹出键盘上方的view(转载)

    这篇文章解决的一个开发中的实际问题就是:当弹出键盘时,自定义键盘上方的view.目前就我的经验来看,有两种解决方法.一个就是利用UITextField或者UITextView的inputAccesso ...

  2. 移动端点击输入框,弹出键盘,底部被顶起问题(vue)

    这个问题相信做移动端开发的童鞋会有深刻体会,以前用jq开发时就很头疼这个问题,每次底部footer部分需要用position:fixed,如果页面内容不是很长,没有超出屏幕范围,那就还好,没有问题:一 ...

  3. ios在数字键盘左下角添加“完成”按钮的实现原理

    本文转载至 http://www.itnose.net/detail/6145865.html 最近要在系统弹出的数字键盘上的左下角额外添加一个自定制的完成按钮,于是研究了一下系统自带键盘添加自定制按 ...

  4. (Vue)移动端点击输入框,弹出键盘,底部被顶起问题

    (Vue)移动端点击输入框,弹出键盘,底部被顶起问题:https://www.jianshu.com/p/210fbc846544 问题描述:Vue开发中,当我们相对于父视图的底部布局子控件时,需要用 ...

  5. js 点击input焦点不弹出键盘 PDA扫描枪

    直接贴代码 1.利用input readonly属性 当input有readonly属性的时候,即使获取焦点,也不会吊起小键盘 扫码枪输入的间隔大概在15-60毫秒,然后手动输入的100-200毫秒之 ...

  6. 关于UITextfield弹出键盘解决方案

    解决的问题:当你点击一个UITextfield时,不想让其弹出键盘,如果你觉得不就是取消其第一响应者嘛,resignRespond一下不就行了嘛,确实,如果你只是在其编辑完成后让其键盘消失,那这个就够 ...

  7. EditText: EditText自动获取焦点并弹出键盘&EditText不自动获取焦点并且不会弹出键盘

    1.EditText不自动获取焦点并且不会弹出键盘 找到EditText的父控件,设置其父控件为: Parent.setFocusable(true); Parent.setFocusableInTo ...

  8. flex 在父窗口监听弹出窗口里的某个按钮被点击

    flex 在父窗口监听弹出窗口里的某个按钮被点击 这样可以从子窗口拿回数据在父窗口处理数据,不必再子窗口中处理.在某些情形下省去了不少麻烦. /** * 右键菜单项单击事件 * changed by ...

  9. MUI - 打开页面默认弹出键盘及返回关闭键盘

    打开页面默认弹出键盘及返回关闭键盘 http://www.cnblogs.com/phillyx/ (function(keyboard) { var openSoftKeyboard = funct ...

随机推荐

  1. Github-素材篇

    my github: http://github.com/yaochao

  2. 动手学servlet(五) 共享变量

    1. 无论对象的作用域如何,设置和读取共享变量的方法是一致的 -setAttribute("varName",obj); -getAttribute("varName&q ...

  3. nginx学习笔记

    我的工作环境是 Debian . 在 Debian 上安装 ngingx 和其他 linux 安装基本相同. 在配置 hello world 之前,没有头绪,看了很多资料.最后 "https ...

  4. C++设计模式-Bridge桥接模式

    作用:将抽象部份与它的实现部份分离,使它们都可以独立地变化. 将抽象(Abstraction)与实现(Implementation)分离,使得二者可以独立地变化. 桥接模式号称设计模式中最难理解的模式 ...

  5. php redis 安装篇(windows 7)

    人人都说redis比memcached好,但是没有实际体验过,概念还是比较模糊,今天就先把redis安装好,后面的体验再分享,由于php已经有了很好的扩展库支持,所以redis安装非常方便,下面是wi ...

  6. 使用 Google Web Fonts

    Google Fonts 的介绍:Google Fonts 并不是简单的字体下载站 Google Fonts 地址:https://www.google.com/fonts 左上角可以输入查找的字体名 ...

  7. (Hibernate进阶)Hibernate基本映射(三)

    介绍Hibernate的经典内容:对象关系映射.主要介绍映射的基本概念,映射的分类,映射文件. 概念 ORM(Object Relational Mapping),即对象关系映射.它的作用就是在关系型 ...

  8. Thinkphp的单字母函数整理

    有人不太喜欢TP这种单字母函数,其实这也是TP的一个特色,如果理解了这些函数的作用,不管是背,还是写,都是非常方便的,接下来我们以字母顺序开始.A函数 B函数 C函数 D函数 F函数 L函数 R函数 ...

  9. python中x,y交换值的问题

    今天碰到了python和其他语言不同的问题:赋值语句 x,y,z=1,2,3,执行 z,x,y=y,z,x 后,x.y.z 中分别含有什么值? 我想的是 x=2  y=2  z=2 可调试后应该是:x ...

  10. Mysql 相关字段类型长度

    1.  Compact行记录是在MySQL 5.0时被引入的,其设计目标是能高效存放数据. 2.  Redundant是MySQL 5.0版本之前InnoDB的行记录存储方式. 3.  InnoDB存 ...