ios - UIAlertController backgroundColor 褪色

标签 ios swift2 uicolor uialertcontroller

尝试设置 UIAlertController backgroundColor 但结果是“褪色”颜色

let alert = UIAlertController(title: "some title", message: "(tap to continue)", preferredStyle: .Alert)
            self.presentViewController(alert, animated: true, completion:{

                let subview = alert.view.subviews.first! as UIView
                let alertContentView = subview.subviews.first! as UIView
                alertContentView.backgroundColor = UIColor.yellowColor()

我所说的“褪色”是指它不是亮黄色,而是更像褪色的黄色......

有什么想法吗?

最佳答案

想法?嗯,在 Apple 内部的层和 View 层次结构中的某个地方,有一些东西是半透明的。你可能会找到它是什么,但你正踏入危险的境地。苹果文档明确指出

You cannot customize the appearance of alert views.

所以即使你解决了这个问题,它也可能无法在所有 iOS 版本或所有设备上运行。如果您需要自定义外观,请不要使用警报 View ;创建您自己的模态视图。

关于ios - UIAlertController backgroundColor 褪色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37060042/

相关文章:

swift - 在 Promisekit 完成运行并在 Swift 中返回正确的值之前循环递增并重新运行

objective-c - 在 NSDictionary 中存储 UIColors 并检索它们?

ios - 使用作为参数传递的 UIColor 设置 CGContextSetStrokeColorWithColor

ios - 将重新排序图标设置为透明 UITableViewCells - moverowat 函数

ios - requestImageForAsset 始终返回 nil - 即使在检查 nil 后也是如此

Swift 2 Parse 和 KingFisher 缓存图像

ios - CIColor 到 UIColor -> CIColor 没有为 UIColor UIExtendedSRGBColorSpace 定义

ios - 在 Xamarin.iOS DYLD 中集成时,代码签名对于 iOS Objective C Umbrella 框架无效,库未加载 : App Crash

ios - 自定义 UICollectionViewCell 增加内存分配

ios - UISearchBar 失去焦点