iOS - UILabel 更改禁用标签的外观
进一步回答我昨天的问题,我正在使用带有 UILabels 的视图,输出到外部监视器。
标签上可以设置文本,除非它们被禁用。但是(显然)禁用的标签的文本显示为灰色。有什么办法可以覆盖这种行为吗?
我唯一能想到做的另一件事是子类化 UILabel 并有一个变量将其设置为可编辑,但这会影响序列化吗?
谢谢!
Further to my question yesterday, I am using a view with UILabels, output to an external monitor.
The labels can have text set on them, unless they are disabled. But (obviously) a disabled label has it's text greyed out. Is there anyway to override this behaviour?
The only other thing I can think of doing is to subclass UILabel and have a variable setting it as editable, but would that affect serialization?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您想阻止用户与标签交互,可以设置一个名为 userInteractionEnabled 的属性。
If you want to prevent user interaction with the label, there is a property named userInteractionEnabled that you can set.
没关系,行为似乎无法改变。我只是对 UILabel 进行了子类化并添加了一个变量来检查它是否可编辑。干杯,伙计们。
Nevermind, it seems that behaviour cannot be changed. I simply subclassed the UILabel and added a variable to check if it was editable. Cheers guys.
是的,可以设置颜色和 alpha 属性。
Yes It is possible set the color and alpha attribute.
如果您需要使用
disabledTextColor
的标签,类似于highlightedTextColor
,您必须子类化 UILabel 并使自定义文本绘制Swift
If you need to have label with
disabledTextColor
, similar tohighlightedTextColor
, you have to subclass UILabel and make custom text drawingSwift