UIAlertController change background color of Cancel button for action sheet

后端 未结 5 1128
死守一世寂寞
死守一世寂寞 2020-12-18 15:38

I am trying to create a UIAlertController with the action sheet style but I want to change the background color to a gray color. I have been able to find a way to change the

5条回答
  •  死守一世寂寞
    2020-12-18 16:07

    If you want a separate Cancel Button(UIAlertActionStyleCancel) you can't change the background color of the cancel button. If it's your priority then you have to make your own custom View. Or else you can simply add a default action with the title "Cancel".

    [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:nil]]

    (But it won't give you a separate button).

    I have debugged the view hierarchy and found this.

提交回复
热议问题