【发布时间】:2021-09-30 05:44:01
【问题描述】:
我已经成功创建了一个自定义的圆形浮动标签栏,但是我怎样才能删除默认的标签栏(如图中的箭头所示)。我尝试将标签栏背景设置为 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)
【问题讨论】:
-
你有没有试过检查superviews是否有背景颜色?
-
@Aswath 是的,它们都没有背景颜色
标签: ios swift xcode uitabbar cashapelayer