What are the correct dimensions for a custom tab bar item background image?

后端 未结 6 688
北海茫月
北海茫月 2021-01-13 15:11

So I have a .png that\'s 428x176 px:

I want to use it as a tab bar background image for when an item is in the selected state. The problem is t

6条回答
  •  无人共我
    2021-01-13 15:39

    Try resizing the image to the tab bar size. Or Add an imageView to the tabBar as subview, and then use the image in that imageView. Subclass the TabBarController and add imageview there:

    class YourTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
        let backgroundImage = UIImageView(image: UIImage(named: "gray background"))
        backgroundImage.frame = backgroundImage.bounds
        self.view.addSubview(backgroundImage)
    
    
    }
    

提交回复
热议问题