Ios textfield子类突出显示文本

Ios textfield子类突出显示文本,ios,uitextfield,Ios,Uitextfield,我将UITextfield子类化,以允许背景图像、占位符文本颜色。它在iPad上的工作与预期一样。但在iPhone上,它一直高亮显示蓝色,看不到任何文本输入。可以看到截图 子类的代码如下所示: - (CGRect) textRectForBounds:(CGRect)bounds { return CGRectInset(bounds, 10, 10); } - (CGRect) editingRectForBounds:(CGRect)bounds { return CGRectInset(

我将UITextfield子类化,以允许背景图像、占位符文本颜色。它在iPad上的工作与预期一样。但在iPhone上,它一直高亮显示蓝色,看不到任何文本输入。可以看到截图

子类的代码如下所示:

- (CGRect) textRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, 10, 10);
}

- (CGRect) editingRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, 10, 10);
}

- (void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor colorWithRed:.533 green:.553 blue:.220 alpha:1.0] setFill];
[[self placeholder] drawInRect:rect withFont:self.font lineBreakMode:NSLineBreakByTruncatingTail alignment:NSTextAlignmentLeft];
}
它可以在iPad上完美运行。这是在模拟器和设备上实现的。
有谁能解释一下这一点。

对于将来面临此类问题的其他人: 事实证明,iphone中textfield的高度较低,因此从上述方法返回的rect不正确。只是减少了插入值,效果很好