清除故事板中使用的标签文本 [英] Clear Label text used in Storyboard

查看:15
本文介绍了清除故事板中使用的标签文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否有人知道如何完成以下...

Wondering if anyone know hows to complete the following...

Storyboard 中,我用虚拟文本设置了标签,它们不是静态文本.例如User1 用户名".

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?

推荐答案

您可以使用用户定义的运行时属性来实现这一点.只需为任何 UILabelUITextFieldUITextView 设置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:

KVC 和运行时属性在使用 Storyboard 时非常强大(例如,您是否知道可以将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?).

这篇关于清除故事板中使用的标签文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆