如何解决使用自定义图层时删除标签栏背景
我已经成功创建了一个自定义的圆形浮动标签栏,但如何删除默认标签栏(如图中箭头所示)。我试图将标签栏背景设置为 UIImage() 并将背景颜色设置为清除,但它仍然无法正常工作。 我的代码:
let layer = CAShapeLayer()
guard let tabBar = tabBarController?.tabBar else {return}
layer.path = UIBezierPath(roundedRect: CGRect(x: 30,y: tabBar.bounds.minY + 5,//y: tabBar.bounds.minY - 28,width: tabBar.bounds.width - 60,height: tabBar.bounds.height - 24),cornerRadius: (tabBar.frame.width / 2)).cgPath
layer.shadowColor = UIColor.lightGray.cgColor
layer.shadowOffset = CGSize(width: 5.0,height: 5.0)
layer.shadowRadius = 25.0
layer.shadowOpacity = 0.3
layer.borderWidth = 1.0
layer.opacity = 1.0
layer.masksToBounds = false
layer.fillColor = UIColor.white.cgColor
tabBar.layer.insertSublayer(layer,at: 0)
解决方法
使用标签栏外观:
let app = UITabBarAppearance()
app.backgroundEffect = .none
app.shadowColor = .clear
tabBar.standardAppearance = app
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。