【问题标题】:Line appears in iOS 7 Textfield行出现在 iOS 7 文本字段中
【发布时间】:2013-09-19 06:06:43
【问题描述】:

我已使用以下代码在 iOS 文本字段中显示彩色占位符。这在 iOS 5 和 6 中运行良好。但在 iOS 7 中,文本字段的中间会出现一行。

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void) drawPlaceholderInRect:(CGRect)rect {
    [SEARCH_FIELD_FONT_COLOR setFill];
    if (self.placeholderFont) {
        [[self placeholder] drawInRect:rect withFont:SEARCH_FIELD_FONT];
    }else {
        [[self placeholder] drawInRect:rect withFont:self.placeholderFont];
    }
}

@end

【问题讨论】:

    标签: ios objective-c uitextfield ios7


    【解决方案1】:

    尝试使用以下代码更改 textFiled 占位符的颜色。

    [self.myTextField setValue:[UIColor darkGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
    

    【讨论】:

    • 您正在使用私有字段“_placeholderLabel”。该应用可能会被拒绝。
    【解决方案2】:

    这可能会更好一些。此外,您可以使用和属性占位符更改字体。

    - (void) drawPlaceholderInRect:(CGRect)rect {
        [SEARCH_FIELD_FONT_COLOR setFill];
    
        [super drawPlaceholderInRect:rect];
    }
    

    【讨论】:

    • @ChrisWagner 我会提交一个错误,因为这应该由文档工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-24
    • 2013-09-24
    • 1970-01-01
    • 1970-01-01
    • 2014-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多