ठीक है तो मेरे पास यह चेतावनी है कि मैं इसका उपयोग कर रहा हूं और मैं चाहता हूं कि इसकी पृष्ठभूमि काले रंग की तरह न हो। मैंने शीर्षक और संदेश के लिए पाठ का रंग बदलने में कामयाब रहा है लेकिन पृष्ठभूमि रंग नहीं। वांछित रंग मैं चाहता हूँ। मैंने इसे हरे नीले और सफेद में बदल दिया है, लेकिन काला नहीं है। जब मैं इसे काला में बदलने की कोशिश करता हूं तो यह भूरे हो जाता है। कोई सुझाव मदद और सराहना की जाएगी। मैंने इसे How to change the background color of the UIAlertController? पर आजमाया और इसी तरह मैं वहां गया जहां मैं हूं।UIAlertcontroller पृष्ठभूमि बदलें रंग
यहाँ अब मैं क्या हो रहा है:
func showAlert(title:String, message:String) {
//Set up for the title color
let attributedString = NSAttributedString(string: title, attributes: [
NSFontAttributeName : UIFont.systemFontOfSize(15), //your font here,
NSForegroundColorAttributeName : UIColor.whiteColor()
])
//Set up for the Message Color
let attributedString2 = NSAttributedString(string: message, attributes: [
NSFontAttributeName : UIFont.systemFontOfSize(15), //your font here,
NSForegroundColorAttributeName : UIColor.whiteColor()
])
let alert = UIAlertController(title: title,message: message, preferredStyle: .Alert)
alert.setValue(attributedString, forKey: "attributedTitle")
alert.setValue(attributedString2, forKey: "attributedMessage")
//alert.view.tintColor = UIColor.whiteColor()
let dismissAction = UIAlertAction(title: "Dismiss", style: .Destructive, handler: nil)
alert.addAction(dismissAction)
self.presentViewController(alert, animated: true, completion: nil)
//set the color of the Alert
let subview = alert.view.subviews.first! as UIView
let alertContentView = subview.subviews.first! as UIView
alertContentView.backgroundColor = UIColor.blackColor()
//alertContentView.backgroundColor = UIColor.greenColor()
//Changes is to a grey color :(
/*
alertContentView.backgroundColor = UIColor(
red: 0,
green: 0,
blue: 0,
alpha: 1.0)
//Also another Grey Color Not batman black
*/
//alertContentView.backgroundColor = UIColor.blueColor()
//turns into a purple
}
@ लुकाडावनजो वास्तव में मुझे इस स्थान पर कैसे पहुंचा। यदि आप मेरे कोड को देखते हैं तो यह – MNM