Why are the parameters in my UIAlertController dull and how can I fix it?

This is strange. I am doing a UIAlertController with the following code:

let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: UIAlertControllerStyle.ActionSheet)

    let action = UIAlertAction(title: "Action 1", style: .Default, handler: {
        (alert: UIAlertAction!) -> Void in
        print("Cancelled")
    })

    let action2 = UIAlertAction(title: "Action 2", style: .Default, handler: {
        (alert: UIAlertAction!) -> Void in
        print("Cancelled")
    })

    let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
        (alert: UIAlertAction!) -> Void in
        print("Cancelled")
    })

    optionMenu.addAction(cancelAction)
    optionMenu.addAction(action)
    optionMenu.addAction(action2)

    self.presentViewController(optionMenu, animated: true, completion: nil)

And here is how it looks on the screen. The options are dull (I suppose you reached out or were affected by the rear views).

Dimmed options

I was able to add this code to make it pure white, but the fine separation goes away.

let subview = optionMenu.view.subviews.first! as UIView
let alertContentView = subview.subviews.first! as UIView
alertContentView.backgroundColor = UIColor.whiteColor()
alertContentView.layer.cornerRadius = 2    

And it looks like this: Without attenuation, but not quite right

Any ideas on how to prevent the background from influencing options in the UIAlertController?

I added this UIAlertController to the page with a white background, and it looked as it should.

Thanks!

+4
source share
2 answers

. "". , . ; , . . . , .

0

c . :

[alert.view setBackgroundColor:[UIColor whiteColor]];

, !

0

Source: https://habr.com/ru/post/1612618/


All Articles