//修改clearButton的位置
- (CGRect)clearButtonRectForBounds:(CGRect)bounds{
[super leftViewRectForBounds:bounds];
CGRect rect = CGRectMake(bounds.size.width - 39, 11, 17, 22);
return rect;
}
//修改左侧图片的位置
- (CGRect)leftViewRectForBounds:(CGRect)bounds{
[super leftViewRectForBounds:bounds];
CGRect rect = CGRectMake( 22, 11, 17, 22);
return rect;
}
// 重写占位符的x值
- (CGRect)placeholderRectForBounds:(CGRect)bounds{
CGRect placeholderRect = [super placeholderRectForBounds:bounds];
placeholderRect.origin.x += 1;
return placeholderRect;
}
// 重写文字输入时的X值
- (CGRect)editingRectForBounds:(CGRect)bounds{
CGRect editingRect = [super editingRectForBounds:bounds];
editingRect.origin.x += 11;
return editingRect;
}
// 重写文字显示时的X值
- (CGRect)textRectForBounds:(CGRect)bounds{
CGRect textRect = [super editingRectForBounds:bounds];
textRect.origin.x += 11;
return textRect;
}
- (CGRect)rightViewRectForBounds:(CGRect)bounds{
UIView *view = self.rightView;
NSLog(@"%@",view);
if ([view isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)view;
for (UIView *view in button.subviews) {
NSLog(@"%@",view);
if ([view isKindOfClass:[UIImageView class]]) {
CGRect rect = CGRectMake(bounds.origin.x + bounds.size.width - 22 - 17, bounds.origin.y + 11, 17, 22);
return rect;
}else if ([view isKindOfClass:[UILabel class]]){
return CGRectMake(self.frame.origin.x + self.frame.size.width - 90, 0, 90, 44);
}else{
return CGRectMake(self.frame.origin.x + self.frame.size.width - 90, 0, 90, 44);
}
}
}
CGRect rect = CGRectMake(bounds.origin.x + bounds.size.width - 22 - 17, bounds.origin.y + 11, 17, 22);
return rect;
}
网友评论