//textField占位文字的位置
-(CGRect)placeholderRectForBounds:(CGRect)bounds{
[super placeholderRectForBounds:bounds];
CGRect newBounds = bounds;
newBounds.origin.x = bounds.origin.x + leftOfView;
return newBounds;
}
//textField输入文字的位置 + 光标的位置
-(CGRect)editingRectForBounds:(CGRect)bounds{
[super editingRectForBounds:bounds];
//光标的颜色
// self.tintColor= [UIColor whiteColor];
CGRect newBounds = bounds;
newBounds.origin.x = bounds.origin.x + leftOfView;
return newBounds;
}
//textField输入完成后的位子
- (CGRect)textRectForBounds:(CGRect)bounds{
CGRect newBounds = bounds;
newBounds.origin.x = bounds.origin.x + leftOfView;
return newBounds;
}
//设置placeHold的颜色+切圆角
-(void)drawRect:(CGRect)rect{
[self setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
self.layer.borderWidth = 2;
self.layer.borderColor = [UIColor whiteColor].CGColor;
self.layer.cornerRadius = 5;
self.layer.masksToBounds = YES;
}
iOS textField设置placeHold的位置,颜色和输入文字的位置,切圆角
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 前言 由于项目需要修改TextField的占位符的颜色,位置等,总结下如何设置UITextField的占位符的一些...
- 这是一个模仿的小例子,记录我在编写过程中所碰到的一些问题。这个是最终效果 主要介绍上面的搜索布局是怎么实现的,注意...
- 在开发过程中,有时候我们需要在UITextField左边放置一个图片,例如想得到下面的效果: 想要得到上面的效果,...