具有自定义视图&的iOS13 UIAlertControllerpreferredStyle作为actionsheet灰度所有颜色 [英] iOS13 UIAlertController with custom view & preferredStyle as actionsheet grayscale all colors

查看:61
本文介绍了具有自定义视图&的iOS13 UIAlertControllerpreferredStyle作为actionsheet灰度所有颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定是错误还是功能,但是代码如下:

I'm not exactly sure if it's a bug or a feature, but this code:

let sheet = UIAlertController(customView: awesomeView, preferredStyle: .actionSheet)
....
present(sheet, animated: true, completion: nil)

在iOS 13之前的版本中,我得到了以下结果:

in pre-iOS 13 gives me this result:

以及在iOS 13上:

and on iOS 13:

即所有customview的元素都是灰度的.我尝试过Tint/Text/Background/...按钮/标签的颜色-在iOS 13中完全没有效果.在旧版本中-用户界面正在更改.

I.e. all the customview's elements have been grayscale. I've tried to play with Tint/Text/Background/... colors of the buttons / label - in iOS 13 is does no effect at all. In older versions - UI is changing.

目标:避免产生灰度效果.

The goal: to avoid the grayscale-effect.

此外,我注意到,如果我将PreferredStyle更改为 .alert (而不是 .actionSheet ),我会重新获得颜色,但是我更喜欢保持今天的布局.

Also, I've noticed that if I change the preferredStyle to .alert(instead of .actionSheet) - I get my colors back, but I'd prefer to keep the layout as it is today.

操作系统:iOS 13及更高版本;Xcode 11-beta 3(beta 1和beta 2也有完全相同的问题)

OS: iOS 13 & Xcode 11 - beta 3 (also had exactly the same problem with beta 1 and 2)

到目前为止,我看到的唯一解决方法是远离 UIAlertController ,但是也许有更好的方法来解决它?

The only workaround I see so far is to stay away from UIAlertController, but maybe there's any better way to fix it?

推荐答案

将自定义视图添加到警报控制器的方式不再起作用.您需要改为通过键路径设置视图:

The way you were adding the custom view to the alert controller doesn‘t work anymore. You need to set the view via keypaths instead: https://github.com/chrs1885/SheetyColors/blob/be0de5cdda9b72f5655a3fdd5e40d4bc54a8c090/SheetyColors/Classes/Common/Views/Extensions/UIAlertController%2BcustomView.swift

这篇关于具有自定义视图&的iOS13 UIAlertControllerpreferredStyle作为actionsheet灰度所有颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆