How to fit the image with the tabbar in swift?

Hi There to apple community.
I want to know how to make the tabbar image fit to the tabbar.
I use this code to set the image:

Code Block swift
   vc.tabBarItem.image = UIImage(named: "myimage")



but the image fill all over the screen.
And when I use systemimages I don't have this problem.

thanks for your help

I think the best is to resize your image to the right size (40*40 for instance)

To resize:
https://stackoverflow.com/questions/31314412/how-to-resize-image-in-swift
More info.

this cannot be done automatically.
According to : https://stackoverflow.com/questions/29708069/how-can-i-decrease-the-size-of-a-ui-tab-bar-item-image-so-that-it-fits-inside-th

From Apple: doc:
Unlike other custom artwork in your app, the icons and images listed in Table 41-1 must meet specific criteria so that iOS can display them properly.


How to fit the image with the tabbar in swift?
 
 
Q