【问题标题】:Change overall tintColor and font-size of UITableViewCellStyleValue2 textLabel in iOS 7在 iOS 7 中更改 UITableViewCellStyleValue2 textLabel 的整体 tintColor 和字体大小
【发布时间】:2014-02-26 08:47:42
【问题描述】:

我有一个 Skinning 模块,我在其中定义了我的应用程序范围 tintColor 以在应用程序中通用:

+ (UIColor*)tintColor
{
    return [UIColor colorWithRed:0.26f green:0.41f blue:1.00f alpha:1.00f];
}

我用它来设置应用的整体色调:

[UIApplication sharedApplication].keyWindow.tintColor = [Skinning tintColor];

但是UITableViewCellStyleValue2 的`textLabel 颜色保持不变。所以我必须这样做:

cell.textLabel.textColor = [Skinning tintColor];

每个单元格。

我想没有设置一次的整体方法,或者有吗?

我对字体大小有同样的问题。默认为 15 点,但在 iOS 设置等中,他们使用 18 点系统字体。

【问题讨论】:

    标签: ios uitableview ios7 tintcolor


    【解决方案1】:

    我之前也遇到过同样的问题,我认为最好的解决方案是编写 UITableViewCell 的自定义子类,并在覆盖的单元格构造函数中设置各种 textLabels 颜色(例如– initWithStyle:reuseIdentifier:)。 在同一位置您还可以设置字体大小。

    另一种方法(似乎不太适合您的情况)是使用UIAppearance 代理表视图单元格中包含的标签,但随后将为每个单元格类、每个标签设置外观(主要和细节),每种风格:

    [[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] setTextColor:[Skinning tintColor]];
    

    似乎没有办法只对某些表格视图单元格样式执行此操作。

    【讨论】:

      猜你喜欢
      • 2013-10-10
      • 2014-03-17
      • 1970-01-01
      • 2011-06-25
      • 2011-11-03
      • 2011-06-14
      • 1970-01-01
      • 1970-01-01
      • 2021-04-22
      相关资源
      最近更新 更多