How to set the buttons label text color for state UIControlStateHighlighted

前端 未结 3 640
日久生厌
日久生厌 2021-01-12 07:01

I am creating an iPhone application in which i have a custom button. i have set the buttons title by creating a Label and adding it as subview. now when the button is highli

3条回答
  •  庸人自扰
    2021-01-12 07:35

    you can add target for UIControlStateHighlighted state of UIButton like

    [button1 addTarget:self action:@selector(buttonHighlighted:) forControlEvents:UIControlStateHighlighted];
    

    and in buttonHighlighted method you can change the color of your label's text

    - (void) buttonHighlighted:(id)sender
    {
      //code here
    }
    

    Hope it gives you an idea.

提交回复
热议问题