0

To keep it as simple as possible, I currently have two storyboard : the "introduction" (containing two buttons : sign up and log in) and the sign up one.

I would like to have the same background for both, so I assumed that putting an ImageView in both of the storyboards was a good idea. Then, I applied a filter on it with this code :

func setAuthenticationBackgroundFilter(background: UIImageView) {
    let gradient = CAGradientLayer()
    gradient.frame = background.bounds
    gradient.colors = [UIColor.init(hex: "#8E1B1B").cgColor, UIColor.init(hex: "#519BF9").cgColor]
    gradient.opacity = 0.75
    background.layer.insertSublayer(gradient, at: 0)
}

It works perfectly but when I'm switching views like that :

    let storyboard = UIStoryboard(name: StoryBoardName.signUp, bundle: nil)
    guard let signUpViewController = storyboard.instantiateInitialViewController() as? SignUpController else {
        return
    }

    self.show(signUpViewController, sender: true)

During the transition, there is a tiny part of the screen which appears without the filter, giving the impression that the screen reset and replace the previous background by the next one (which are basically the same).

TL;DR : I would like to switch from one view to one another with the animation but I also would like to keep the same background (+filter) and change the content of the view without having this "background resetting" impression (FOR ONLY A FEW VIEWS, not all).

Can I have any help on this matter please ?

Thank you !

Edit : I already read this one - How can I add the same background image to all views in my ios app using swift? , but this is not the same case. I am not trying to put the same background to ALL the views of the app, only a few ones. Therefore I don't think changing the UIWindow in the AppDelegate would help my case... (or maybe ?)

NPanda
  • 41
  • 9

0 Answers0