change UIAlertcontroller background Color

前端 未结 7 900
孤城傲影
孤城傲影 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:40

    For Objective C, the below code works like charm.

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Save changes?" message:nil preferredStyle:UIAlertControllerStyleAlert];
    
    UIView *firstSubview = alertController.view.subviews.firstObject;
    
    UIView *alertContentView = firstSubview.subviews.firstObject;
    
    for (UIView *subSubView in alertContentView.subviews) { //This is main catch
        subSubView.backgroundColor = [UIColor blueColor]; //Here you change background
    }
    
    0 讨论(0)
提交回复
热议问题