textview 弹出键盘上面添加完成按钮,并设置输入内容的格式。
- (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 弹出键盘上面添加完成按钮,并设置输入内容的格式。的更多相关文章
- IOS开发之自定义系统弹出键盘上方的view(转载)
这篇文章解决的一个开发中的实际问题就是:当弹出键盘时,自定义键盘上方的view.目前就我的经验来看,有两种解决方法.一个就是利用UITextField或者UITextView的inputAccesso ...
- 移动端点击输入框,弹出键盘,底部被顶起问题(vue)
这个问题相信做移动端开发的童鞋会有深刻体会,以前用jq开发时就很头疼这个问题,每次底部footer部分需要用position:fixed,如果页面内容不是很长,没有超出屏幕范围,那就还好,没有问题:一 ...
- ios在数字键盘左下角添加“完成”按钮的实现原理
本文转载至 http://www.itnose.net/detail/6145865.html 最近要在系统弹出的数字键盘上的左下角额外添加一个自定制的完成按钮,于是研究了一下系统自带键盘添加自定制按 ...
- (Vue)移动端点击输入框,弹出键盘,底部被顶起问题
(Vue)移动端点击输入框,弹出键盘,底部被顶起问题:https://www.jianshu.com/p/210fbc846544 问题描述:Vue开发中,当我们相对于父视图的底部布局子控件时,需要用 ...
- js 点击input焦点不弹出键盘 PDA扫描枪
直接贴代码 1.利用input readonly属性 当input有readonly属性的时候,即使获取焦点,也不会吊起小键盘 扫码枪输入的间隔大概在15-60毫秒,然后手动输入的100-200毫秒之 ...
- 关于UITextfield弹出键盘解决方案
解决的问题:当你点击一个UITextfield时,不想让其弹出键盘,如果你觉得不就是取消其第一响应者嘛,resignRespond一下不就行了嘛,确实,如果你只是在其编辑完成后让其键盘消失,那这个就够 ...
- EditText: EditText自动获取焦点并弹出键盘&EditText不自动获取焦点并且不会弹出键盘
1.EditText不自动获取焦点并且不会弹出键盘 找到EditText的父控件,设置其父控件为: Parent.setFocusable(true); Parent.setFocusableInTo ...
- flex 在父窗口监听弹出窗口里的某个按钮被点击
flex 在父窗口监听弹出窗口里的某个按钮被点击 这样可以从子窗口拿回数据在父窗口处理数据,不必再子窗口中处理.在某些情形下省去了不少麻烦. /** * 右键菜单项单击事件 * changed by ...
- MUI - 打开页面默认弹出键盘及返回关闭键盘
打开页面默认弹出键盘及返回关闭键盘 http://www.cnblogs.com/phillyx/ (function(keyboard) { var openSoftKeyboard = funct ...
随机推荐
- Tomcat Connector三种运行模式(BIO, NIO, APR)的比较和优化
Tomcat Connector的三种不同的运行模式性能相差很大,有人测试过的结果如下: 这三种模式的不同之处如下: BIO: 一个线程处理一个请求.缺点:并发量高时,线程数较多,浪费资源. Tomc ...
- mysql数据备份
转载自:http://blog.chinaunix.net/uid-16480950-id-102800.html http://www.cnblogs.com/xuejie/archive/20 ...
- [Linux编程] module_param()函数学习笔记
在读TCP cubic源码中,遇到了module_param(),网上查到的资料如下: 在用户态下编程可以通过main()来传递命令行参数,而编写一个内核模块则可通过module_param()来传递 ...
- [转]基于AWS的自动化部署实践
作者 徐桂林 发布于 2014年1月22日 -------------------------------------------------------------------- 1. 背景 在过去 ...
- HDU2048
http://acm.hdu.edu.cn/showproblem.php?pid=2048 这道题是错位排序的思想 我们先来考虑第n个数,假设把他放在第k的位置,有n-1种放的方法,那么对于第k位置 ...
- 安装SQl 2008为SQL Server代理服务提供的凭据无效
解决:安装SQl 2008为SQL Server代理服务提供的凭据无效 sql server 2008 代理服务提供的凭据无效sql server 2008 代理服务提供的凭据无效在Windows S ...
- Sqlserver 自定义表类型定义,使用,删除
--创建用户自定义表类型CREATE TYPE dbo.CustomerTable AS TABLE ( Id int NOT NULL, Name char(10) NULL, PRIMARY KE ...
- arrayList的合并以及删除重复元素
arrayList的合并: package listTest;//arrayList的合并 import java.util.ArrayList; public class arrayListTest ...
- mysql优化笔记
query_cache_size 查询缓存 query_cache_type缓存是否打开 OFF/ON read_buffer_size读缓存SET GLOBAL query_cache_size=1 ...
- 提权GrantPrivilege
大概一个多月前学习了提权的知识,当时一直不知道提权到底具体是为了干什么.只是模糊的知道提高权限,获得别的进程的一些东西.后来慢慢的学习的多了,知道了一个叫做ReadProcessMemory的函数,第 ...