Just like the tabbar, I want to show badge on UISegmentedControl
. As I cant see any predefined methods for UISegmentedControl
just like available for UITabBar
.
I thought about adding the badge as an image just on top of it, but maybe there is some better way.
UISegmentedControl Language: Language: Swift Objective-C API Changes: Show Class UISegmented Control. A horizontal control that consists of multiple segments, each segment functioning as a discrete button. Availability. iOS 2.0+ Mac Catalyst 13.0+ tvOS 9.0+ Framework. UIKit; On This Page ...
There are two UISegmentedControl objects on the app screen. The above one is added to the Main.storyboard visually, when click it’s item, it will display the item title or image in the above label. The bottom one is added in swift source code, when click it’s item, it will prompt an alert dialog to display the selected item title text.
How To Add UISegmentedControl Component Visually In Main.storyboard Steps. Create an Xcode project using the Single View App template. Click the Main.storyboard file in the project files list to edit it. Click Xcode View —> Show Library menu item to open the UI component object library window.
A horizontal control that consists of multiple segments, each segment functioning as a discrete button. A segmented control can display a title (an NSString object) or an image ( UIImage object). The UISegmentedControl object automatically resizes segments to fit proportionally within their superview unless they have a specific width set.
Here is a little third party library I've used to draw badges on various things. It's pretty nice. For example, changing the color of the badge to match my design was trivial.
Once you bring this class into your project and include it into your view controller, you go:
CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:@"Badge 1"];
...and then add customBadge1 as a subview of whatever thing you're badging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With