iOS textField设置placeHold的位置,颜色和输
//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的位置,颜色和输
本文链接:https://www.haomeiwen.com/subject/sassmttx.html
网友评论