如何为 UILabel 设置文本颜色,我使用标签获得


[[self.view viewWithTag:thisTag].layer setTextColor:[UIColor redColor]];

这行不通。

我假设你没有收到错误消息;否则你可能会发布它。所以我假设如下:
thisTag是视图层次结构中不存在的标记。在这种情况下,viewWithTag:将返回nil 。然后你layer发送消息,然后setTextColor: nil,这什么也不做。
如果viewWithTag:将返回一个UIView对象,您将获取其layer属性,然后将其发送到setTextColor:,这不是为CALayer对象定义的,因此会给您一条错误消息。

最新更新