Minitour / AZTabBarController

A custom tab bar controller for iOS written in Swift 4.2
MIT License
348 stars 65 forks source link

Weird Issue: Just one image does not set #65

Closed StackHelp closed 4 years ago

StackHelp commented 4 years ago

I am trying to set different images in TabBar but just one image from them doesn't work.

    var icons = [UIImage]()
    icons.append(UIImage(named: "ic_tab_wallpaper")!)
    icons.append(UIImage(named: "ic_tab_maps")!)
    icons.append(UIImage(named: "ic_tab_wallpaper")!)
    icons.append(UIImage(named: "ic_tab_shop")!)
    icons.append(UIImage(named: "ic_tab_profile")!)

    var sIcons = [UIImage]()
    sIcons.append(UIImage(named: "ic_tab_wallpaper_selected")!)
    sIcons.append(UIImage(named: "ic_tab_maps")!)
    sIcons.append(UIImage(named: "ic_tab_wallpaper_selected")!)
    sIcons.append(UIImage(named: "ic_tab_shop_selected")!)
    sIcons.append(UIImage(named: "ic_tab_profile_selected")!)

Every other image except ic_tab_maps works and shows in TabBar. I have tried to check in your example as well but it doesn't work.

Screenshot 2020-04-30 at 1 40 59 PM

Minitour commented 4 years ago

Are your images placed in the XCAssets catalog?

StackHelp commented 4 years ago

@Minitour Yes. Edited a question. Please check the tabbar

Minitour commented 4 years ago

Oh it’s the second one... yeah this is because it automatically sets the image to have a tint color and because your image doesn’t have an alpha it colors all of it.

To fix this you have two options:

StackHelp commented 4 years ago

@Minitour the image is with alpha 100%. I don't understand the second option. First option works though

Minitour commented 4 years ago

I’ll rephrase. You are correct the image has an alpha component, but the part of it which you wish to view is not transparent.

Either get rid of the rectangle surrounding the map pin, or get a rectangle with map in cut out of it.