如何检查UIButtons标题是否等于特定的字符串? [英] How to check if a UIButtons title is equal to a specific string?

查看:51
本文介绍了如何检查UIButtons标题是否等于特定的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试有一个可以单击的按钮,如果标题是该字符串,它将执行x操作,否则选择否.

I am trying to have a button that you can click and it will do x if the title is that string, other wise no.

if button.setTitle("Message", for: .normal) == true {

} else {

}

推荐答案

您可以使用

You can use the currentTitle property to check the value you want.

应该使用 setTitle 方法设置/更新标题值,而不是获取它.

The setTitle method should be used to set/update the title value, not get it.

这篇关于如何检查UIButtons标题是否等于特定的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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