How to set the background color in turbolinks-ios?

207 views Asked by At

I'm experimenting with the turbolinks-ios adapter for turbolinks 5.

Apparently, the background color of the VisitableView is white. But when the background color of the web application is not white, the turbolinks transition does not look so good: When clicking a link, the background becomes white and changes back to the desired background color once the content is loaded.

The obvious solution would be to set the iOS app's background color, but how?

Demo Application

Turbolinks for iOS has a demo application that may serve as an example context if this makes it easier to answer the question.

The demo app can be found here: https://github.com/turbolinks/turbolinks-ios/tree/master/TurbolinksDemo

1

There are 1 answers

0
fiedl On BEST ANSWER

This did work:

In the ApplicationController's presentVisitableForSession(), set the visitable.visitableView.backgroundColor.

For example:

// 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)
    }
}