2

recently, I updated my Xcode 13 and my navigationBar broke like this:

not what I want to do

it's same code and same Xcode but in iOS 15 simulator, scrollEdgeAppeance's shadow override standard one. it should be like this(same code in iOS 14 simulator).

what I want to do

here's my code (I turned shadow image to solid image to see clearly):

class MyViewController: UINavigationViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        let standard = UINavigationBarAppearance()
        standard.configureWithOpaqueBackground()
        standard.backgroundColor = .systemBlue
        standard.shadowImage = UIImage(color: .black)
        standard.shadowColor = .clear
        navigationBar.standardAppearance = standard
        
        let scroll = UINavigationBarAppearance()
        scroll.configureWithOpaqueBackground()
        scroll.backgroundColor = .systemRed
        scroll.shadowImage = UIImage()
        scroll.shadowColor = .clear
        navigationBar.scrollEdgeAppearance = scroll
    }
}   

it changes background color when scroll(large title ↔ standard title) but shadow image is not working.

how can I do?

what I want to do:

  1. I use solid image in example however I want to use alpha gradated shadow image. (not a template line shadow. it's important.)
  2. in large title appearance(scrollEdgeAppearance I think), shadow should not be appear.
  3. in standard title appearance(standardAppearance I think), shadow should be appear.
이동근
  • 103
  • 7

0 Answers0