【问题标题】:What is this button artefact when UIButton is selected?选择 UIButton 时,这个按钮伪像是什么?
【发布时间】:2013-07-15 11:07:53
【问题描述】:

我正在尝试使用以下代码将 UI Button 设为切换按钮:

- (void)tapButton:(id)sender{
    UIButton *button = sender;
    if (!button.selected){
        [self performSelector:@selector(highlight:) withObject:button afterDelay:0.0];
    }else{
        [self performSelector:@selector(removeHighlight:) withObject:button afterDelay:0.0];
    }
}

- (void)highlight:(UIButton *)button{
    button.selected = !button.selected;
    button.highlighted = YES;
}

- (void)removeHighlight:(UIButton *)button{
    button.selected = !button.selected;
    button.highlighted = NO;
}

但是,当按钮处于选定模式时,我得到了一个奇怪的伪像。

未选择:

已选择:

【问题讨论】:

    标签: ios uibutton uikit selected uicontrol


    【解决方案1】:

    只需将按钮类型设置为“自定义”而不是“系统”。我猜这个奇怪的错误与 iOS7 上的新 Tint 功能有关。这可能是错误的,因为您的 title 属性是一个空字符串 @""。

    【讨论】:

    • 谢谢。非常感谢。
    猜你喜欢
    • 2019-01-21
    • 2015-11-12
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    相关资源
    最近更新 更多