【问题标题】:How to set the background color in turbolinks-ios?如何在 turbolinks-ios 中设置背景颜色?
【发布时间】:2016-08-13 07:33:48
【问题描述】:

我正在为turbolinks 5 使用turbolinks-ios 适配器。

显然,VisitableView 的背景颜色是白色。但是当 Web 应用程序的背景颜色不是白色时,turbolinks 过渡看起来就不那么好了:单击链接时,背景变为白色,并在加载内容后变回所需的背景颜色。

显而易见的解决方案是设置 iOS 应用的背景颜色,但如何设置?

演示应用程序

Turbolinks for iOS 有一个演示应用程序,如果这样更容易回答问题,可以用作示例上下文。

可在此处找到演示应用程序: https://github.com/turbolinks/turbolinks-ios/tree/master/TurbolinksDemo

【问题讨论】:

    标签: ios uiwebview turbolinks-ios


    【解决方案1】:

    这确实有效:

    ApplicationController's presentVisitableForSession()中,设置visitable.visitableView.backgroundColor

    例如:

    // ApplicationController.swift
    class ApplicationController: UINavigationController {
        // ...
    
        func bgColor() -> UIColor? {
            return UIColor(red: 0, green: 103/255, blue: 170/255, alpha: 1)
        }
    
        private func presentVisitableForSession(session: Session, URL: NSURL, action: Action = .Advance) {
            let visitable = MainViewController(URL: URL)
    
            visitable.visitableView.backgroundColor = bgColor()    // <-- ADD THIS LINE
    
            if action == .Advance {
                pushViewController(visitable, animated: true)
            } else if action == .Replace {
                popViewControllerAnimated(false)
                pushViewController(visitable, animated: false)
            }
    
            session.visit(visitable)
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-11
      • 1970-01-01
      • 2021-03-23
      • 2018-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多