【问题标题】:How can I get the text color of a system UITableVIewCell's detail label?如何获取系统 UITableVIewCell 详细信息标签的文本颜色?
【发布时间】:2012-02-09 12:23:45
【问题描述】:

我真的很喜欢这种感觉。

还有一些其他系统颜色,我在 UIColor 文档中找不到它们的 API,

如nib文件中按钮的默认文字颜色等

那么有什么方法可以使用它们吗?

我的意思是,它们只是颜色,没有风险,对吧?

或者是否有任何与它们相似的 RGBA 值?非常感谢!

【问题讨论】:

  • 我想你问的是 cell.detailTextLabel.textColor?

标签: ios system rgb textcolor


【解决方案1】:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
    [[cell detailTextLabel] textColor]

textColor 只会返回单元格 detailTextLabel 的 UIColor 对象。

【讨论】:

  • 打印出来相当于[UIColor colorWithRed:0.22 green:0.33 blue:0.53 alpha:1],仅供参考。
  • 从 iOS 9 开始,返回值为 Color:UIDeviceRGBColorSpace 0.556863 0.556863 0.576471 1,或 RGB 值从 0-255,(142, 142, 147)。
【解决方案2】:

通过将模拟器的屏幕截图拉到 Photoshop 中,我得到以下值:

[UIColor colorWithRed:0.22 green:0.33 blue:0.55 alpha:1.0]

在设备上看起来非常接近我的眼睛。但是 muffe2k 的答案总是有效的。

【讨论】:

    【解决方案3】:

    我将[UIColor grayColor] 用于UITableViewCell.detailsTextLabel.textColor。乍一看,grayColor 和原始颜色没有区别。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-24
      • 1970-01-01
      • 2016-05-20
      • 1970-01-01
      • 2015-05-11
      • 2015-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多