change UIAlertcontroller background Color

前端 未结 7 904
孤城傲影
孤城傲影 2021-02-02 15:09

Ok so I have this alert that I am using and I want the background of it to be black not grey like it is. I have managed to change the colour of the text for the title and the me

7条回答
  •  执念已碎
    2021-02-02 15:24

    In case someone wants to have an opaque white background color he can do this with this one liner:

    UIVisualEffectView.appearance(whenContainedInInstancesOf: [UIAlertController.classForCoder() as! UIAppearanceContainer.Type]).backgroundColor = UIColor.white
    

    Note however this will work properly only with white color as other colors will appear differently because of the default visual effect.

提交回复
热议问题