美文网首页
UINavigationBar 下面的 黑线

UINavigationBar 下面的 黑线

作者: plantAtree_dAp | 来源:发表于2017-03-23 19:58 被阅读66次

iOS之navigationBar背景

iOS之navigationBar背景

让导航栏变透明,去掉导航栏下面的线



iOS开发小结 - UINavigationBar设置shadowImage


        let size = self.navigationController!.navigationBar.frame.size
        UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.mainScreen().scale)
        var context = UIGraphicsGetCurrentContext()
        UIColor.blueColor().setFill()
        CGContextAddRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, 2))
        CGContextDrawPath(context, .Fill)
        var image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

        self.navigationController?.navigationBar.shadowImage = image

        UIGraphicsBeginImageContextWithOptions(CGSizeMake(size.width, size.width+20), false, UIScreen.mainScreen().scale)
        context = UIGraphicsGetCurrentContext()
        UIColor.redColor().setFill()
        CGContextAddRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, size.height+20))
        CGContextDrawPath(context, .Fill)
        image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

        self.navigationController?.navigationBar.setBackgroundImage(image, forBarMetrics: .Default)


相关文章

网友评论

      本文标题:UINavigationBar 下面的 黑线

      本文链接:https://www.haomeiwen.com/subject/dovtottx.html