uialertcontroller
How to change the background color of the UIAlertController?
You have to step some views deeper: let subview = actionController.view.subviews.first! as UIView let alertContentView = subview.subviews.first! as UIView alertContentView.backgroundColor = UIColor.blackColor() And maybe you want to keep original corner radius: alertContentView.layer.cornerRadius = 5; Sorry for the “Swifting” but i’m not familiar with Objective-C. I hope that’s similar. Of course it’s also important to change … Read more
UIAlertController tint color defaults to blue on highlight
This is a known Bug, see https://openradar.appspot.com/22209332 To fix it, reapply the tint color in the Completion handler. Here’s my Swift Solution, you will be able to adapt it easily for ObjC: alertController.view.tintColor = UIColor.redColor() // apply 1st time to prevent flicker from Blue to Red when displaying navigationController?.presentViewController(alertController, animated: true, completion: { // Bugfix: … Read more
Showing a UIPickerView with UIActionSheet in iOS8 not working
From the reference for UIActionSheet: UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:. My guess is your seeing exactly why. The … Read more
Present UIAlertController from AppDelegate [duplicate]
You can use this code as well if you want to launch it from didFinishLaunchingWithOptions.Hope this helps. dispatch_async(dispatch_get_main_queue(), { let importantAlert: UIAlertController = UIAlertController(title: “Action Sheet”, message: “Hello I was presented from appdelegate ;)”, preferredStyle: .ActionSheet) self.window?.rootViewController?.presentViewController(importantAlert, animated: true, completion: nil) }) And up-to-date: DispatchQueue.main.async { let alert = UIAlertController(title: “Hello!”, message: “Greetings from AppDelegate.”, … Read more
‘UIAlertView’ was deprecated in iOS 9.0. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead
See this Code Destructive and OK buttons in UIAlertController: let alertController = UIAlertController(title: “Destructive”, message: “Simple alertView demo with Destructive and Ok.”, preferredStyle: UIAlertControllerStyle.alert) //Replace UIAlertControllerStyle.Alert by UIAlertControllerStyle.alert let DestructiveAction = UIAlertAction(title: “Destructive”, style: UIAlertActionStyle.Destructive) { (result : UIAlertAction) -> Void in print(“Destructive”) } // Replace UIAlertActionStyle.Default by UIAlertActionStyle.default let okAction = UIAlertAction(title: “OK”, style: … Read more
Show alert in AppDelegate in Swift [duplicate]
This is what i’m using now to do that. var alertController = UIAlertController(title: “Title”, message: “Any message”, preferredStyle: .ActionSheet) var okAction = UIAlertAction(title: “Yes”, style: UIAlertActionStyle.Default) { UIAlertAction in NSLog(“OK Pressed”) } var cancelAction = UIAlertAction(title: “No”, style: UIAlertActionStyle.Cancel) { UIAlertAction in NSLog(“Cancel Pressed”) } alertController.addAction(okAction) alertController.addAction(cancelAction) self.window?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
How to change UIAlertController button text colour in iOS9?
I’ve run into something similar in the past and the issue seems to stem from the fact that the alert controller’s view isn’t ready to accept tintColor changes before it’s presented. Alternatively, try setting the tint color AFTER you present your alert controller: [self presentViewController:strongController animated:YES completion:nil]; strongController.view.tintColor = [UIColor black];