textfield控制光标开始位置
// UIView *paddingView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 50)];
// paddingView1.backgroundColor = [UIColor lightGrayColor];
// self.phoneTextField .leftView = paddingView1;
// self.phoneTextField.leftViewMode = UITextFieldViewModeAlways;
// [self.view addSubview:paddingView1];
//
// self.phoneTextField = [[UITextField alloc]initWithFrame:CGRectMake(10, 0, self.view.frame.size.width,textFieldH )];
// self.phoneTextField.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"手机" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
// self.phoneTextField.delegate = self;
// self.phoneTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
// self.phoneTextField.returnKeyType = UIReturnKeyDone;
// [paddingView1 addSubview:self.phoneTextField];
这是第一种办法,就是添加leftview
第二种就是自定义UItextField
#import <UIKit/UIKit.h>
@interface textField : UITextField
//控制 placeHolder 的位置,左右缩 10
- (CGRect)textRectForBounds:(CGRect)bounds;
// 控制文本的位置,左右缩 10
- (CGRect)editingRectForBounds:(CGRect)bounds;
@end
textField.m
#import "textField.h"
@implementation textField
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset( bounds , 10*1 , 0 );
}
// 控制文本的位置,左
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectInset( bounds , 10*1 , 0 );
}
@end
textfield控制光标开始位置的更多相关文章
- android EditText控制光标的位置
利用自定义键盘,需要手动删除编辑框中的文本时,会根据光标的位置来删除字符.那么,如何来控制光标呢,android为我们提供了哪些方法,来处理光标呢? 这里提供几个自己写的方法,根据这些方法可以满足在光 ...
- iOS-textfield控制光标开始位置
// UIView *paddingView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.wi ...
- Delphi 操作Word怎么控制光标的位置
unit ControlWordS; interface uses Classes, Sysutils, Word97; type TControlWord = class(TComponent) ...
- js 控制光标到指定位置
js控制光标到指定节点位置(适用于富文本编辑器中) function placeCaretAtEnd(el) { //传入光标要去的jq节点对象 el.focus(); if (typeof wind ...
- 控制input输入框光标的位置
一:理解input, textarea元素在标准浏览器下两个属性selectionStart, selectionEnd. selectionStart: 该属性的含义是 选区开始的位置: selec ...
- “Win10 UAP 开发系列”之 在MVVM模式中控制ListView滚动位置
这个扩展属性从WP8.1就开始用了,主要是为了解决MVVM模式中无法直接控制ListView滚动位置的问题.比如在VM中刷新了数据,需要将View中的ListView滚动到顶部,ListView只有一 ...
- 设置输入域(input/textarea)中文本光标的位置
以前记录了一篇 将光标定位于输入框最右侧的实现方式 ,实现光标定位在文本的最末.这种需求往往在修改现有的文本.有时可能还需要把光标定位在首位,或者中间某个位置,这就需要实现一个更通用的方法. 这个方法 ...
- android EditText插入字符串到光标所在位置
EditText mTextInput=(EditText)findViewById(R.id.input);//EditText对象 int index = mTextInput.getSelect ...
- UITextField 光标的位置设置获取
UITextField 光标的位置设置获取 通过给UITextField 加一个拓展 //#import "UITextField+ExtentRange.h" #import & ...
随机推荐
- 采用 PAT工具及CSP语言,对一个问题进行自动机 建模
pat是新加坡国立开发的工具,需要的去官网下http://www.comp.nus.edu.sg/~pat/ ,学了一天,是个不错的自动机验证工具,感觉还不错啊. 验证一个数是否为斐波那契数且为质数 ...
- oracle的增删改查语句
创建一个表: cteate table 表名(列1 类型, 列2 类型);查看表结构 desc表名添加一个字段 alter table 表名 add(列类型);修改字段类型 alter table 表 ...
- strcat()函数常见问题
strcat(char *_Destination,const char *_Source)函数的功能是将后一个字符串粘贴到前一个字符串的末尾 原型 char *strcat(char *_Desti ...
- db2 常用命令(二)
1. 打开命令行窗口 #db2cmd 2. 打开控制中心 # db2cmd db2cc 3. 打开命令编辑器 db2cmd db2ce ======脚本文件操作命令======= -- 执行脚本 ...
- SQL Server 2005中更改sa的用户名和密码
修改数据库SA账号名称的代码如下: 代码如下: Alter LOGIN sa DISABLE Alter LOGIN sa WITH NAME = [systemAccount] "sys ...
- 备忘:文本编辑器(z.B. Sublime Text 2)策略,git策略
1.以Sublime Text 2 为例: 新建一个test.py文件,敲完例程 代码 之后,再另存为比如 if.py, list_tuple.py云云 而test.py可以一直用来编辑 2.git ...
- [转]Ionic – Mobile UI Framework for PhoneGap/Cordova Developers
本文转自:http://devgirl.org/2014/01/20/ionic-mobile-ui-framework-for-phonegapcordova-developers/ Ionic i ...
- [转]Ionic最佳实践-使用模态窗口modal
本文转自:http://m.blog.csdn.net/blog/betreex/45649689 原文地址:Ionic最佳实践-使用模态窗口modal 模态窗口的结构 在Ionic中,模态窗口通过$ ...
- OpenSSH后门获取root密码及防范
OpenSSH后门获取root密码及防范 相对于Windows操作系统,Linux操作系统的密码较难获取.而很多Linux服务器都配置了Openssh服务,在获取root权限的情况下,可以通过修改或者 ...
- Codeforces Round #275 Div.1 B Interesting Array --线段树
题意: 构造一个序列,满足m个形如:[l,r,c] 的条件. [l,r,c]表示[l,r]中的元素按位与(&)的和为c. 解法: 线段树维护,sum[rt]表示要满足到现在为止的条件时该子树的 ...