Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 隐藏导航栏和内容之间的分隔符行_Ios_Swift_Uiview_Uinavigationcontroller_Uinavigationbar - Fatal编程技术网

Ios 隐藏导航栏和内容之间的分隔符行

Ios 隐藏导航栏和内容之间的分隔符行,ios,swift,uiview,uinavigationcontroller,uinavigationbar,Ios,Swift,Uiview,Uinavigationcontroller,Uinavigationbar,我想删除导航栏和ImageView橙色之间的连接线: 有人知道怎么做吗 修改AppDelegate文件并添加以下代码: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launc

我想删除导航栏和ImageView橙色之间的连接线:

有人知道怎么做吗

修改AppDelegate文件并添加以下代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    // Change status bar color to white
    UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent

    // To remove separtor line between navigation controller and view
    UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
    UINavigationBar.appearance().shadowImage = UIImage()
    return true
}

在我的例子中,我实现了以下代码

override func viewDidLoad() {
    super.viewDidLoad()

    if self.navigationController != nil {
        hideBorder(self.navigationController!.navigationBar)
    }
}

func hideBorder(view: UIView) -> Bool {
    if view.isKindOfClass(UIImageView.classForCoder()) && view.frame.size.height <= 1 {
        view.hidden = true
        return true
    }

    for sub in view.subviews {
        if hideBorder(sub as! UIView) {
            return true
        }
    }
    return false
}
在视图中添加以下行将显示


我不认为你可以删除这条线,这是一个视图和导航控制器之间的分离。我建议在视图本身中隐藏导航并添加导航项,这看起来和感觉上都像整个视图。
for parent in self.navigationController!.navigationBar.subviews {
        for childView in parent.subviews {
            if(childView is UIImageView) {
                childView.removeFromSuperview()
            }
        }
    }
self.navigationController?.navigationBar.shadowImage = UIImage()