ios - 如何在 UIButton 上设置一个不可见的标题?

标签 ios objective-c uibutton title alpha

我正在开发一个 Ipad 应用程序,我需要在“UIButton”上设置一个标题,以便可以使用:

-(void)MyMethod:(id)sender
{
    UIButton *resultButton = (UIButton *)sender;
    if ([resultButton.currentTitle isEqualToString:@"TitleName"])
    {
        ...
    }
}

但是当我使用这种代码时:

[MyUibutton setTitle:@"TitleName" forState:UIControlStateNormal];

它出现在“UIButton”图像后面的“TitleName”...

那么,是否可以修复它?

谢谢!

最佳答案

不要使用按钮标题,它是为了显示,而不是标志。而是使用 tagobjc_setAssociatedObject 或者将按钮存储在字典中并进行比较。

关于ios - 如何在 UIButton 上设置一个不可见的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18806795/

相关文章:

ios - 我可以从我的 UIViewController 中的 UINavigationController 继承吗?

ios - React-native:panResponder 内部的 ScrollView

ios - swift/图表 : chart value int instead of double

objective-c - 当前有关高级内存管理的 Apple 文档是否有轻微的不准确之处?

ios - 如何在移动 slider 时更改按钮的背景颜色?

iphone - CoreFoundation 中的 CFStringGetLength 导致 iOS 崩溃

c++ - 在 Cocoa 项目中使用 C++ 类时找不到标准 C++ 包含

iphone - 由 Interface Builder 创建的 UIButton 崩溃了

ios - 如何通过单击其他按钮取消选择图像?

iphone - 背景中的 UILocalNotification 响亮的声音