Storyboard中使用的清除标签文本 [英] Clear Label text used in Storyboard
问题描述
想知道是否有人知道如何完成以下操作......
Wondering if anyone know hows to complete the following...
在故事板中
我设置了我的标签使用虚拟文本,它们不是静态文本。例如'User1 Username'。
In a Storyboard
I set my Labels with dummy text, they are not Static text. For example 'User1 Username'.
如果有一个设置在视图加载时清除此标签的值,我将会知道。我还有一些其他代码可以运行并收集相关信息。但是,可能需要几秒钟才能在用户加载时向用户显示HUD。
What I would to know if there is a setting to clear the value of this label when it is loaded by the view. I have some other code that runs off and collects the relevant information. However, it might take a few seconds so a HUD is shown to the user whilst it loads.
当然,在HUD的背景中,您可以看到显示的示例文本。我知道在 viewDidLoad
我可以简单地清除所有标签文本,将它们设置回 @
,但是没有故事板中的设置或其他任何内容?
Of course in the background of the HUD you can see the example text shown. I know in viewDidLoad
I could simply clear all the label texts setting them back to @""
, but is there no setting in the storyboard or anything for this?
推荐答案
您可以使用用户定义的运行时属性来实现这个。只需为任何 UILabel , UITextField 或 UITextView 设置text属性即可获得所需内容:
You can use User Defined Runtime Attributes to achieve this. Simply set "text" attribute for any UILabel, UITextField or UITextView to get what you want:
使用Storyboard时,KVC和运行时属性非常强大(例如,您是否知道可以将layer.cornerRadius属性设置为任何UIView以获取舍入的角落?)。
KVC and runtime attributes are really powerfull when working with Storyboard (e.g. did you know that you can set "layer.cornerRadius" attribute to any UIView to get rounded corners?).
这篇关于Storyboard中使用的清除标签文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!