【问题标题】:Objective-C: What is the actual color of a textfields placeholder text?Objective-C:文本字段占位符文本的实际颜色是什么?
【发布时间】:2016-01-22 21:01:01
【问题描述】:

我试过弄乱红色、绿色、蓝色的各个值。但似乎无法获得正确的颜色。

例如

[UIColor colorWithRed:0.80 green:0.80 blue:0.80 alpha:1.0];

谢谢

编辑

感谢 Satish A 将我推向正确的方向。

我得到的 UITextField.placeholder 的 UIColor 是

[UIColor colorWithRed:196.0/255.0 green:193.0/255.0 blue:110.0/255.0 alpha:1.0]

【问题讨论】:

    标签: objective-c xcode colors placeholder


    【解决方案1】:

    尝试以下:

    覆盖drawPlaceholderInRect:(CGRect)rect 以手动呈现占位符文本:

    - (void) drawPlaceholderInRect:(CGRect)rect {
        [[UIColor blueColor] setFill];
        [[self placeholder] drawInRect:rect withFont:[UIFont systemFontOfSize:16]];
    }
    

    [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-12
      • 2018-06-07
      • 1970-01-01
      • 1970-01-01
      • 2021-12-16
      • 2017-05-01
      • 2017-10-03
      相关资源
      最近更新 更多