I want to add a custom badge to the UITabBar.

Asked 2 years ago, Updated 2 years ago, 111 views

I'd like to put a red circle badge on the UITabBar, but I don't know how to do it even if I google it.

I found a library like the one below, but I couldn't do it well.
https://github.com/evgenyneu/swift-badge
Thank you for your cooperation.

swift xcode uikit uitabbarcontroller

2022-09-30 19:32

1 Answers

UIBarItem has the image(UIImage) property, so I think I should set the UIImage created with UIGraphicsBeginImageContext.

Compositing Images and Text UIGraphicsBeginImageContext

Or do you use SF Symbols?
I probably can't set the color details, but

You can also set the SF Symbols color using UIImage.withTintColor().
https://techlife.cookpad.com/entry/2021/01/05/custom-symbols-ja


2022-09-30 19:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.