Perhaps you can tell me what options or settings affect this issue
Post
Replies
Boosts
Views
Activity
I suspect that iOS 18 may have some upgrades and optimizations for animations, which may result in some changes in the view hierarchy for view push or pop. Unfortunately, I did not get more information from the official documentation.
In order to describe the problem more clearly, I have uploaded some files and demo, hoping to understand my difficulties。
My first controller:
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.red
// Do any additional setup after loading the view.
let companyLogo = UIImageView(image:#imageLiteral(resourceName: "logo"))
navigationItem.titleView = companyLogo
let customView = UIView(frame: CGRect(x: 200, y: 5, width: 40, height: 20))
customView.backgroundColor = UIColor.blue
navigationController?.navigationBar.addSubview(customView)
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.green
button.frame = CGRect(x: 100, y: 300, width: 100, height: 100)
self.view.addSubview(button)
button.addTarget(self, action: #selector(clickAction), for: .touchUpInside)
}
Button click event:
@objc private func clickAction() {
let second = SecondViewController()
navigationController?.pushViewController(second, animated: true)
}
When I execute a back in SecondViewController, during this animation process, customeview is briefly overwritten by navigationItem.titleView. I want to know why this is happening?