2013-07-17 41 views
4

我试图通过使用此代码做一个UI按钮切换按钮:当选择UIButton时,这个按钮是什么东西?

- (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; 
} 

但是,我得到一个奇怪的假象,当按钮处于选择的模式。

未选择:

enter image description here

选择:

enter image description here

回答

4

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

+0

Thanx。非常感激。 – smileBot

相关问题