中间凸起的tabbar ios
iOS13以上才行
import UIKit class CustomTabBarController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() setupTabBarAppearance() addCenterButton() } private func setupTabBarAppearance() { let appearance = UITabBarAppearance() appearance.configureWithOpaqueBackground() appearance.backgroundColor = .white tabBar.standardAppearance = appearance tabBar.scrollEdgeAppearance = appearance } private func addCenterButton() { let button = UIButton(type: .system) button.setImage(UIImage(systemName: "plus"), for: .normal) // 使用系统图标作为示例 button.tintColor = .blue // 设置按钮颜色 button.addTarget(self, action: #selector(centerButtonTapped), for: .touchUpInside) button.frame = CGRect(x: 0, y: 0, width: 60, height: 60) // 设置按钮大小和位置 button.center = tabBar.center // 将按钮置于tab bar中心 button.layer.zPosition = 1 // 确保按钮在tab bar之上 tabBar.addSubview(button) // 将按钮添加到tab bar上 tabBar.bringSubviewToFront(button) // 确保按钮在最前面 } @objc private func centerButtonTapped() { print("Center button tapped") } }
在北京的灯中,有一盏是我家的。这个梦何时可以实现?哪怕微微亮。北京就像魔鬼训练营,有能力的留,没能力的走……

浙公网安备 33010602011771号