Xcode中,如何将Tab Bar Item设置成自定义按钮?

2025-05-02 09:26:51
推荐回答(1个)
回答1:

private func initButton()
    {
        let ButtonWidth = self.tabBar.frame.size.width / 5
        let ButtonHeight = self.tabBar.frame.size.height
        let Button = UIButton(frame:CGRect(origin: CGPointMake(ButtonWidth * 2, 0), size:CGSizeMake(ButtonWidth,ButtonHeight)))
        Button.backgroundColor = UIColor.blackColor()
        Button.setBackgroundImage(UIImage(named:"bookmark_filled-50.png"), forState:UIControlState.Normal)
        Button.addTarget(self, action:"ButtonClick:", forControlEvents: UIControlEvents.TouchUpInside)
        self.tabBar.addSubview(Button)