objective-c - 当用户单击时如何禁用 UIButton 的突出显示

标签 objective-c ios uibutton

我正在做一个 UIButtion,单击后突出显示,再次单击时不突出显示。当我点击时,我无法取消突出显示。我在下面创建了一个事件监听器

  • (IBAction)ButtonClicked:(UIButton*)sender
    {

    [sender setHighlighted:!sender.isHighlighted];
    

    }

编辑: 目标操作是

 [button addTarget:self action:@selector(ButtonClicked:) forControlEvents:UIControlStateSelected];

最佳答案

[sender setSelected:!sender.isSelected] 试试这个:)如果这就是你想要的

关于objective-c - 当用户单击时如何禁用 UIButton 的突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9619115/

相关文章:

ios - iOS7 上的 UITextfield leftView/rightView 填充

ios - 遵循 CGPathRef 的不准确之处

ios - tvOS 中的 UIButton 自定义背景颜色

ios - UIButton:将背景图像设置为禁用状态会更改默认状态的显示

objective-c - 有没有办法检查 C 或 Objective-C 中的宏 "expands"

ios - 将字符串作为标签或按钮中的其他值传递

ios - __weak 貌似保留了对象

ios - 带有页面 View Controller 的 removeFromSuperView

iphone - 在 UITableView 中延迟加载图像

ios - 在 Cocos2D V3 中单击时展开的 Sprite 按钮