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で完璧に動作します。そして、これはシミュレーターとデバイスの両方にあります。誰でもこれに光を当てることができますか?