裁剪自定义 uitabbar swift

Clipped custom uitabbar swift

我想在中心制作圆形按钮,但我得到了这样的剪裁按钮:

这是我的代码:

class CustomTabBarVC: UITabBarController, UITabBarControllerDelegate {

    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        self.delegate = self
        self.selectedIndex = 1
        setupMiddleButton()
    }

    func setupMiddleButton() {
        let middleButton = UIButton(frame: CGRect(x: (self.view.bounds.width / 2) - 25, y: -25,
                                                  width: 50, height: 50))

        middleButton.setBackgroundImage(UIImage(named: "close-icon-gold"), for: .normal)
        middleButton.layer.shadowColor = UIColor.black.cgColor
        middleButton.layer.shadowOpacity = 0.1
        middleButton.layer.shadowOffset = CGSize(width: 4, height: 4)

        self.tabBar.addSubview(middleButton)
        self.tabBar.bringSubviewToFront(middleButton)
        middleButton.clipsToBounds = false
        middleButton.addTarget(self, action: #selector(menuButtonAction), for: .touchUpInside)

        self.view.layoutIfNeeded()
    }

    @objc func menuButtonAction(sender: UIButton) {
        self.selectedIndex = 2
    }

}
let middleView = UIView(frame: CGRect(x: (tabController!.tabBar.bounds.width / 2)-(70/2), y: -20, width: 70, height: 70))
let middleButton = UIButton(frame: CGRect(x: 10, y: 10, width: 50, height: 50))
middleButton.layer.cornerRadius = centerButton.frame.size.width / 2.0
middleButton.setBackgroundImage(UIImage(named: "close-icon-gold"), for: .normal)
middleView.addSubview(middleButton)
tabController!.tabBar.addSubview(middleView)
tabController!.tabBar.bringSubviewToFront(middleButton)