0

I am facing an issue and read almost all the related topic in StackOverFlow.

When keyboard open in chat VC nav bar moves up. When I do scrolling behavior it's going blurry to translucent.

I just want it not to do anything be be stabil on my brand color.

This is the code in viewdidappear

        navigationController!.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
        navigationItem.backBarButtonItem?.tintColor = .white
        
        
        navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        navigationController?.navigationBar.shadowImage = UIImage()

and this is the func works when keyboard is called or dismissed

1) 
    func setDoneOnKeyboard() {
        
            let keyboardToolbar = UIToolbar()
            keyboardToolbar.sizeToFit()
            let flexBarButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
            let doneBarButton = UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(dismissKeyboardCompose))
            doneBarButton.tintColor = UIColor(named: "BrandPurple")
            keyboardToolbar.items = [flexBarButton, doneBarButton]
            self.typeInput.inputAccessoryView = keyboardToolbar
        

    }
2) this is added as an observer.
    @objc func adjustForKeyboard(notification: Notification) {
        
        guard let keyboardValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
        
        let keyboardScreenEndFrame = keyboardValue.cgRectValue
        
        let keyboardViewEndFrame = view.convert(keyboardScreenEndFrame, from: view.window)
        
        if notification.name == UIResponder.keyboardWillHideNotification {
            chatTableView.contentInset = .zero
        } else {
            //Modify the top insets to 350 and the height of the keyboard > 10 ? 10 : 10
            //to eliminate the gap between the bottom cell and the textView
            chatTableView.contentInset = UIEdgeInsets(top: 500 , left: 0, bottom: keyboardViewEndFrame.height > 10 ? 10 : 10, right: 0)
        }
        chatTableView.scrollIndicatorInsets = chatTableView.contentInset
    }
    

I want it to be fixed color, not move anywhere :D

I tried almost every version of navbar options. Need help.

Ugur Usta
  • 21
  • 1
  • 4

0 Answers0