textView和textField
来源:互联网 发布:淘宝反渗透膜 编辑:程序博客网 时间:2024/06/03 17:22
在viewDidLoad中实现下面的方法
//实现光标的在最上面显示
[textView addObserver:selfforKeyPath:@"contentSize"options:NSKeyValueObservingOptionNewcontext:nil];
在viewDidLoad外面实现下面的方法
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
UITextView *textView = object;
textView.contentOffset = (CGPoint){.x =0,.y = 0};
}
textField
//该方法 放在外面调用
-(void)setPadding:(BOOL)enable top:(float)top right:(float)right bottom:(float)bottom left:(float)left
{
isEnablePadding = enable;
paddingTop = top;
paddingRight = right;
paddingBottom = bottom;
paddingLeft = left;
}
//设置 光标位置
- (CGRect)textRectForBounds:(CGRect)bounds {
if (isEnablePadding) {
return CGRectMake(bounds.origin.x +paddingLeft,
bounds.origin.y +paddingTop,
bounds.size.width -paddingRight, bounds.size.height -paddingBottom);
}
else{
return CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
}
}
#pragma mark //控制placeHolder的颜色、字体
- (void)drawPlaceholderInRect:(CGRect)rect{
[LOGINANDREGISTER_COLORsetFill];
[[selfplaceholder]drawInRect:rect withFont:[UIFont systemFontOfSize:NAVIGATION_TITLE_TEXTSIZE]];
}
//控制placeHolder的位置,左右缩20
-(CGRect)placeholderRectForBounds:(CGRect)bounds
{
//return CGRectInset(bounds, 20, 0);
CGRect inset ;
inset = CGRectMake(15,30, 200, bounds.size.height);
if (IOS_DEVICE>=7) {
inset = CGRectMake(13,35, 200, bounds.size.height);//”13“光标位置
}
return inset;
}
//重写 UITextField右边“X”图标 的位置
- (CGRect)clearButtonRectForBounds:(CGRect)bounds{
CGRect inset ;
inset = CGRectMake(self.frame.size.width-20,33, 15, 15);
if (IOS_DEVICE>=7) {
inset = CGRectMake(self.frame.size.width-20,31, 15, 15);
}
return inset;
}
- textView和textField
- textField和textView字数限制
- textField和textView字数限制
- textField和textView的inputAccessoryView属性
- textField和textView的inputAccessoryView属性
- textView和textField 限制文字输入字数
- TextField和TextView 的一些不同点
- TextField和TextView字数超出截取问题
- 改变textView和textField的光标属性
- 归纳笔记03:TextField和TextView
- [iOS]如何在textField和textView中隐藏键盘
- iOS中TextField 和 TextView 控件的基本使用
- 禁止textField和textView的复制粘贴菜单:
- Xcode_7 iOS_9 textField和textView 关闭键盘 Objective-C (1)
- ios textfield和textView完美简单的字数限制
- textField和textView同时存在时的键盘监听
- iOS 怎么限制textView和textField的输入字数
- iOS swift3.0 监听textField和textView的键盘事件
- SPOJ2666--Query On a Tree Ⅳ
- 机器学习算法汇总:人工神经网络、深度学习及其它
- STC-ISP快捷键
- Python的正则表达式(一)
- 待字闺中之相伴一生分析
- textView和textField
- weka[11] - DBSCAN
- linux下mysql主从同步配置
- ubuntu上安装sphinx报错
- HDUJ 2017 字符串统计
- 在线扩大数据库UNDO表空间
- nginx在windows下的安装,以及编写启动关闭nginx等操作的脚本
- CDC保存为各种格式图像
- 让你提前认识软件开发(37):研发流程初探