iOS-Swift

iOS开发 - iOS13隐藏UITabbar分割线

2019-10-08  本文已影响0人  来者可追文过饰非

直接上代码

   func hideTabbarLine() {
        let rect = CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight)
        UIGraphicsBeginImageContext(rect.size)
        let context = UIGraphicsGetCurrentContext()
        context?.setFillColor(UIColor.clear.cgColor)
        context?.fill(rect)
        
        let img = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        
        if #available (iOS 13.0, *) {
            let appearace = tabBar.standardAppearance.copy()
            appearace.backgroundImage = img
            appearace.shadowColor = .clear
            tabBar.standardAppearance = appearace
        } else {
            tabBar.backgroundImage = img
            tabBar.shadowImage = img
        }
    }
上一篇下一篇

猜你喜欢

热点阅读