- (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. java安全沙箱(二)之.class文件检验器

    java是一种类型安全的语言,它有四类称为安全沙箱机制的安全机制来保证语言的安全性,这四类安全沙箱分别是: 类加载体系 .class文件检验器 内置于Java虚拟机(及语言)的安全特性 安全管理器及J ...

  2. CentOS下安装LAMP环境

    1.安装Apache yum -y install httpd # 开机自启动 chkconfig httpd on # 启动httpd 服务 service httpd start #安装apach ...

  3. Linux disk_partition_dev_马士兵_note

    一般装Linux会遇到的问题: 找不到硬件驱动 现在主流的一些硬件 不支持Linux驱动   尽量找主流的硬件,尽量找老一点的硬件   装系统: 1.记下 系统 ---->到时候要找驱动   2 ...

  4. 【HOW】SharePoint如何彻底删除用户

    在网站中打开“人员和组”,在选中某一用户后,一般只有“从用户组中删除用户”操作.此操作只能将此用户从此用户组中删除,却不能从网站集中彻底删除. 要将用户从网站集中彻底删除,可按如下步骤操作: 1. 在 ...

  5. OS X 系统,修改hosts文件后不生效的问题

    系统版本 OS X El Capitan,10.11.2 问题描述 业务需要,配置“nexus”为某个ip,如下图更改了 /etc/hosts 文件. 结果在ping的时候,请求并未发到指定ip上. ...

  6. Codeforces Round #232 (Div. 2) D. On Sum of Fractions

    D. On Sum of Fractions Let's assume that v(n) is the largest prime number, that does not exceed n; u ...

  7. Oracle数据库监听服务无法启动

    (1) 安装好Oracle后,启动Net Manager,测试orcl失败,报错“ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务”,需要修改监听文件.修改前: # list ...

  8. JS 学习(四)对象

    对象 在JS中,对象是数据(变量),拥有属性和方法. JS中所有事物都是对象:字符串.数字.数组.日期等. 对象是拥有属性和方法的特殊数据类型. 属性是与对象相关的值. 方法是能够在对象上执行的动作. ...

  9. SpingMVC ModelAndView, Model,Control以及参数传递

    1.web.xml 配置: <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class& ...

  10. 如何存session,取session

    存session: Session["codes"] =要存的session字段 用哈希函数存多个: System.Collections.Hashtable hs = new S ...