Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS中的暗模式问题_Ios_Swift_View - Fatal编程技术网

iOS中的暗模式问题

iOS中的暗模式问题,ios,swift,view,Ios,Swift,View,我正在开发一个应用程序,其中设置了一个开关按钮,当开关打开时,我将整个应用程序视图更改为暗模式,当关闭时,它将恢复到其原始视图。现在,当我将应用程序更改为暗模式时,它将完全改变,但当我单击任何文本字段并打开键盘时,它将使我的整个视图变暗。看不到任何文本字段或按钮,这是为什么?我的暗黑代码和默认主题是 struct Theme { static var backgroundColor:UIColor? static var buttonTextColor:UIColor? static var

我正在开发一个应用程序,其中设置了一个开关按钮,当开关打开时,我将整个应用程序视图更改为暗模式,当关闭时,它将恢复到其原始视图。现在,当我将应用程序更改为暗模式时,它将完全改变,但当我单击任何文本字段并打开键盘时,它将使我的整个视图变暗。看不到任何文本字段或按钮,这是为什么?我的暗黑代码和默认主题是

struct Theme {

static var backgroundColor:UIColor?
static var buttonTextColor:UIColor?
static var labelBackgroundColor:UIColor?
static var labelTextColor:UIColor?
static var buttonBackgroundColor:UIColor?
static var tableViewBackgroundColor:UIColor?
static var tableViewCellBackgroundColor:UIColor?
static var tabBarBackgroundColor:UIColor?
static var imageBackgroundColor:UIColor?


static public func defaultTheme() {
    self.backgroundColor = UIColor.white
    self.buttonTextColor = UIColor.black
    self.buttonBackgroundColor = UIColor.white
    self.labelBackgroundColor = UIColor.white
    self.labelTextColor = UIColor.black
    self.tableViewBackgroundColor = UIColor.white
    self.tableViewCellBackgroundColor = UIColor.white
    self.tabBarBackgroundColor = UIColor.white
    self.imageBackgroundColor = UIColor.clear
    updateDisplay()
}

static public func darkTheme() {
    self.backgroundColor = #colorLiteral(red: 0.2605174184, green: 0.2605243921, blue: 0.260520637, alpha: 1)
    self.buttonTextColor = UIColor.white
    self.buttonBackgroundColor = UIColor.clear
    self.labelBackgroundColor = UIColor.clear
    self.labelTextColor = UIColor.white
    self.tableViewBackgroundColor = UIColor.clear
    self.tableViewCellBackgroundColor = UIColor.white
    self.tabBarBackgroundColor = #colorLiteral(red: 0, green: 0.1673184633, blue: 0.3710786104, alpha: 1)
    self.imageBackgroundColor = UIColor.clear
    updateDisplay()
}

static public func updateDisplay() {
    let proxyButton = UIButton.appearance()
    proxyButton.setTitleColor(Theme.buttonTextColor, for: .normal)
    proxyButton.backgroundColor = Theme.buttonBackgroundColor

    let proxyView = UIView.appearance()
    proxyView.backgroundColor = backgroundColor

    let proxyLabel = UILabel.appearance()
    proxyLabel.backgroundColor = Theme.labelBackgroundColor
    proxyLabel.textColor = Theme.labelTextColor

    let proxyTableView = UITableView.appearance()
    proxyTableView.backgroundColor = Theme.tableViewBackgroundColor

    let proxyTableViewCell = UITableViewCell.appearance()
    proxyTableViewCell.backgroundColor = Theme.tableViewCellBackgroundColor

    let proxyTabBar = UITabBar.appearance()
    proxyTabBar.barTintColor = Theme.tabBarBackgroundColor

    let proxyImage = UIImageView.appearance()
    proxyImage.backgroundColor = Theme.imageBackgroundColor
}
} 现在我只是这样称呼它,
Theme.darkTheme()
in-app delegate,当开关按钮打开时。当黑暗模式打开时,我点击文本字段,键盘打开,它会像这样隐藏视图


我怎样才能解决这个问题?

哪一个是1。组件在那里,你就是看不到它们。2.所有的东西上面都有一个视图3.所有的组件都向上移出屏幕了吗?试着只评论一下这行,当你在黑暗的视图中时,试着点击Xcode中的“调试视图层次结构”按钮。您将能够在调试器中看到屏幕上所有视图的所有层。即1。组件在那里,你就是看不到它们。2.所有的东西上面都有一个视图3.所有的组件都向上移出屏幕了吗?试着只评论一下这行,当你在黑暗的视图中时,试着点击Xcode中的“调试视图层次结构”按钮。您将能够在调试器中看到屏幕上所有视图的所有层。