ios - 在 iOS 7 中更改 UITableViewCellStyleValue2 textLabel 的整体 tintColor 和字体大小

标签 ios uitableview ios7 tintcolor

我有一个 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 磅系统字体。

最佳答案

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

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

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

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

关于ios - 在 iOS 7 中更改 UITableViewCellStyleValue2 textLabel 的整体 tintColor 和字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22028870/

相关文章:

ios - ParseFacebookUtilsV4 与 CocoaPods - "framework not found Parse for architecture x86_64"

ios - 重新加载 TableView 时获取索引错误

ios - 重新加载 UITableView 数据并向下滚动到最后选择的单元格

iOS 7 应用程序不会填满 Xcode 6 模拟器中的整个屏幕

带有 uitabbarcontroller 的 ios 7 bottomLayoutGuide

objective-c - 重复 NSTimer 锁定 UI 线程

ios - 不兼容的指针类型从NSString分配给“UITextField”

ios - 如何更改 Swift 3 中 UISearchBar "cancel"按钮的颜色?

ios7 - -[__NSCFStringboundingRectWithSize :options:attributes:context:]: unrecognized selector sent to instance

iOS7:没有 GCD,自定义单元格中的 UILabel 文本不会出现