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

后端 未结 6 686
北海茫月
北海茫月 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:33

    Have you tried with adding imageView as subview of tabbar

    var bgView: UIImageView = UIImageView(image: UIImage(named: "background.png"))
    bgView.frame = CGRectMake(0, 420, 320, 60)//you might need to modify this frame to your tabbar frame
    self.view.addSubview(bgView)
    

    If we talk about height & width of tabbar ,it is 320*49 / 640*98 @2x for standard tabbar. so if you want to keep same dimension try with these width/height ratio.

提交回复
热议问题