Ios UIbutton轻触后更改颜色

Ios UIbutton轻触后更改颜色,ios,uibutton,uikit,ios7,Ios,Uibutton,Uikit,Ios7,我有一个ui按钮,它有一个预设的文本字体和颜色,我需要在点击按钮时立即更改 我尝试: - (IBAction)tapAction : (id)sender { // determine button from tag .. [crtBtn setTitleColor:self.selectedTextColor forState:UIControlStateSelected]; [crtBtn setTitleColor:self.selectedTextColor for

我有一个
ui按钮
,它有一个预设的文本字体和颜色,我需要在点击按钮时立即更改

我尝试:

- (IBAction)tapAction : (id)sender 
{
    // determine button from tag ..
   [crtBtn setTitleColor:self.selectedTextColor forState:UIControlStateSelected];
   [crtBtn setTitleColor:self.selectedTextColor forState:UIControlStateNormal];
   [crtBtn setTitleColor:self.selectedTextColor forState:UIControlStateApplication];
   [crtBtn setTitleColor:self.selectedTextColor forState:UIControlStateHighlighted];    
   [crtBtn setNeedsDisplay];
}
有没有办法解决这个问题?

试试下面的代码:

 - (IBAction)tapAction : (id)sender 
    {  
    [sender setTitleColor:self.selectedTextColor forState:UIControlStateNormal]
    }
请尝试以下代码:

 - (IBAction)tapAction : (id)sender 
    {  
    [sender setTitleColor:self.selectedTextColor forState:UIControlStateNormal]
    }

我认为,您没有为自己设置IBOutlet按钮(使用crtBtn)


我认为,您没有为自己设置IBOutlet按钮(使用crtBtn)

这对我很有用:

-(IBAction)tapAction: (UIButton *)sender 

{

 [crtBtn setTitleColor:self.selectedTextColor forState:UIControlStateNormal];

}
这对我很有用:

-(IBAction)tapAction: (UIButton *)sender 

{

 [crtBtn setTitleColor:self.selectedTextColor forState:UIControlStateNormal];

}

你说的是标题颜色还是按钮背景颜色。?你说的是标题颜色还是按钮背景颜色。?