0

Gradient background is not applied for navigation bar on iPhoneX. This is my function code:

    func setGradientBackground(Colors: [UIColor]) {

    var updatedFrame = bounds
    updatedFrame.size.height += self.frame.origin.y

    if UIDevice().userInterfaceIdiom == .phone {
        if UIScreen.main.nativeBounds.height == 2436{
            updatedFrame.size.height += 44
        } else {
            updatedFrame.size.height += 20
        }

    }

    let gradientLayer = CAGradientLayer(frame: updatedFrame, colors: Colors)
    setBackgroundImage(gradientLayer.createGradientImage(), for: UIBarMetrics.default)

}

Here is the result for iPhoneX

Noura Aziz
  • 57
  • 1
  • 7

0 Answers0