skip to Main Content

I want to remove that line and shadow type bar in navigation bar

1

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let stroryboard = UIStoryboard.init(name: "Main", bundle: nil)
        let rootVC = stroryboard.instantiateViewController(withIdentifier: "DetailViewController") as! DetailViewController
        if let data = arrlist.object(at: indexPath.row) as? NSDictionary{
            rootVC.dictData = data
        }
        self.navigationController?.pushViewController(rootVC, animated: true)
        let backImg = UIImage(named: "backArrowWhite")
        self.navigationController?.navigationBar.backIndicatorImage = backImg
        self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = backImg
        self.navigationController?.navigationBar.tintColor = .black
        self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItem.Style.plain, target: nil, action: nil)
        UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
        UINavigationBar.appearance().shadowImage = UIImage()
        UINavigationBar.appearance().backgroundColor = UIColor.clear
        UINavigationBar.appearance().isTranslucent = true
}

i did these code to remove it
but it has 0 effect how can i remove ??

2

Answers


  1. Chosen as BEST ANSWER
    navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
    navigationController?.navigationBar.shadowImage = UIImage()
    navigationController?.navigationBar.isTranslucent = true
    

    i got my answer i just removed apparance lines and changed it to three line wrote it in viweDidLoad()

    worked...


  2. For me this worked fine

    extension UIViewController {
    func hideSeparationLine() {
        navigationController?.navigationBar.standardAppearance.shadowColor = .clear
        }
    }
    

    I have made extension on viewController and called it in viewDidLoad in first controller in navigation stack

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search