0

I have subclassed UITextfield to allow background image, placeholder text color. It is working as expected in iPad. But on iPhone, it keeps on highlighting blue color and no text entry can be seen. The screenshot can be seen here

The code for subclass is as follows:

- (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];
}

It works perfectly on iPad. And this is both on simulator and device. Can anyone shed some light on this.

4

1 回答 1

0

对于将来面临此类问题的其他人:原来 iphone 中文本字段的高度较小,因此从上述方法返回的 rect 不正确。只是降低了插图值,它就像一个魅力。

于 2013-09-07T05:30:30.250 回答