问题描述
我在XIB中创建了一个没有图像的自定义UIButton.单击该按钮时,标题消失.
I have created in the XIB a custom UIButton with no image. When the button is clicked, the title disappears.
这些答案对我没有帮助,因为我没有任何可以覆盖文字的图像
These answers didn't help me because, I do not have any image that can overlap the text
这也没有帮助,因为我没有任何背景色
This didn't help either, because I do not have any background color
这个人也没有帮助
推荐答案
在XIB中,您可以通过更改 State Config
然后为以下各项设置标题来为每个不同的状态设置标题.相应的状态.在下面的示例中,我将 Default
状态标题设置为 Title
,并将 Highlighted
状态标题设置为单个空格,从而使其显示为在应用程序中为空白.但是请注意,预览仅显示 Default
设置,并且不会针对不同的配置进行更新(请参见下图).
In an XIB, you can set the title for each of the different states by changing the State Config
and then setting the title for the corresponding state. In the following example, I have set the Default
state title to Title
and the Highlighted
state title to a single space, which makes it appear as blank in the app. Note however, that the preview only shows the Default
settings, and does not update for the different configurations (see images below).
默认状态标题
突出显示的州标题
这篇关于自定义,无图像UIButton标题消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!