iOS app ,Swift开发
需要给底部bar的顶部加上个分割线,之前参考别人的OC代码,搞了没有效果,查了一下,原来是13以后不支持了,需要特殊处理。
let rect =CGRect.init(x:0,y:0,width:ScreenWidth,height:1)
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context!.setFillColor(COLOR_TAB_BORDER.cgColor)
context!.fill(rect)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIView.transition(with:self.tabBar, duration:0.5, options: .transitionCrossDissolve) {
if#available(iOS13.0, *) {
letappearance =self.tabBar.standardAppearance.copy()
appearance.backgroundImage=UIImage.init()
appearance.shadowImage= img
self.tabBar.standardAppearance= appearance
}
else{
self.tabBar.backgroundImage=UIImage.init()
self.tabBar.shadowImage= img
}
} completion: { Bool in
}
网友评论