- (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. STM8 EEPROM:

    stm8的EEPROM的搽除是写0,FLASH_PRO与FLASH_DATA写的秘钥顺序相反 EEPROM读写前要解锁的.这个很简单,在技术文档里讲得很清楚.我用一个宏定义来代表EEPROM单元.#d ...

  2. POSTMAN发起请求收到乱码 http 406错误

    web前段异常: The resource identified by this request is only capable of generating responses with charac ...

  3. 在Excel中将数字转换为大写

    123.09 = 壹佰贰拾叁元零玖分 =SUBSTITUTE(SUBSTITUTE(IF(G10<0,"負","")&TEXT(TRUNC(ABS ...

  4. SIP 解析

    1 general-header类: 为描述消息基本属性的通用头域,可用于请求消息或响应消息:通用头域的域名只有在协议版本改变时才可有效地扩展.不过,通信中的所有方均认为是“通用头域”的新的头域也可认 ...

  5. OpenGL学习笔记2——顶点数组

    #pragma comment(lib,"glut32.lib") #pragma comment(lib,"glut.lib") #pragma commen ...

  6. Ubuntu12.04安装到U盘里

    把linux安装到U盘里,随时随地使用自己的系统show一下不仅用起来顺手而且很方便携带.看了一些关于安装Ubuntu到U盘的资料,自己试着折腾了几次,并且成功安装了.花时间更新要保证系统是最新的就要 ...

  7. 微信公众平台实现pc端网站登录

    亲测通过 1,pc端生成带有当前会话的sessionid的url(通过微信来扫描) 2,扫描后,微信浏览器将访问url,将微信浏览器中的sessionid改成通过url传过来的session(pc端) ...

  8. ant批量执行Jmeter脚本

    JDK,Jmeter默认已经装了 ANT下载:http://ant.apache.org/bindownload.cgi ant环境变量需要配置 ant_home,你解压之后的地址 然后PATH环境变 ...

  9. iPad 控件 UIPopoverPresentationController 使用 iPhone可用

    UIPopoverController 在iOS9之后被废弃了,,, iOS8 新控件UIPopoverPresentationController可运用在iphone和iPad上,使用基本同 UIP ...

  10. Product Backlog

    会议时间:周四中午13:20-14:20 会议地点:寝室 讨论了如何根据用户故事来写排球的程序.如何实现单机模式的基本加分判断胜负的功能.并选出项目测试人员.然后两个人一个小组进行程序基本功能的开发. ...