Search code examples
iosobjective-ciphoneuibuttontextcolor

UIButton title text color


I'm setting text color for UIButton

headingButton.titleLabel.textColor = [UIColor colorWithRed:36/255.0 
                                                     green:71/255.0 
                                                      blue:113/255.0 
                                                     alpha:1.0];

It's not changing color same code I'm using in another code it's working.


Solution

  • use

    Objective-C

    [headingButton setTitleColor:[UIColor colorWithRed:36/255.0 green:71/255.0 blue:113/255.0 alpha:1.0] forState:UIControlStateNormal];
    

    Swift

    headingButton.setTitleColor(.black, for: .normal)