相关疑难解决方法(0)

如何将UIAppearance代理属性应用于UILabel?

在尝试将UIAppearance代理样式应用于UILabel类代理时,我得到了不可靠的结果.例如,以下工作正如我所期望的那样:

[[UILabel appearance] setFont:[UIFont fontWithName:SOME_FONT size:SOME_SIZE]];
[[UILabel appearance] setShadowColor:[UIColor blackColor]];
Run Code Online (Sandbox Code Playgroud)

但是,设置textColor不起作用:

[[UILabel appearance] setColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)

确实有效.有点.它有点不可靠,导致任何特定于实例的调用setTextColor:被忽略.

将UIAppearance样式应用于UILabel的正确方法是什么?

uilabel ios uiappearance

30
推荐指数
1
解决办法
1万
查看次数

如何在iOS中全局更改字体大小

我正在尝试编写扩展,以更改UIControl组件字体大小

extension UIViewController {

func changeFontSize(){
    for v in self.view.subviews{
        var fontSize = CGFloat(10)
        if let V = v as? UIButton       {V.titleLabel?.font = V.titleLabel?.font.withSize(fontSize)}
        if let V = v as? UILabel        {V.font = V.font.withSize(fontSize)}
        if let V = v as? UITextField    {V.font = V.font?.withSize(fontSize)}
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是一些组件,如UITableView,如何访问单元格元素,以及UITableView节头组件,以便我使扩展也更改所有类型文本字体的所有子视图?

ios swift

1
推荐指数
1
解决办法
518
查看次数

标签 统计

ios ×2

swift ×1

uiappearance ×1

uilabel ×1