【发布时间】:2013-09-06 08:18:00
【问题描述】:
我将 UITextfield 子类化为允许背景图像、占位符文本颜色。它在 iPad 中按预期工作。但在 iPhone 上,它一直突出显示蓝色,看不到任何文字输入。截图可见here
子类代码如下:
- (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 上完美运行。这在模拟器和设备上都有。 任何人都可以对此有所了解。
【问题讨论】:
标签: ios uitextfield