iosswifttableviewnavigationbaruiappearance

how to remove shawdow of navigation bar in ios?


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 ??


Solution

  • 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...