Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISegmentedControl with badge number

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.

alt text

I thought about adding the badge as an image just on top of it, but maybe there is some better way.

like image 653
Tariq Avatar asked Nov 02 '10 11:11

Tariq


People also ask

What is uisegmentedcontrol language?

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 ...

How to add uisegmentedcontrol in Swift app?

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 do I add a uisegmentedcontrol component to a storyboard?

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.

What is segmented control in Uis?

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.


1 Answers

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.

like image 55
Dan Ray Avatar answered Sep 19 '22 23:09

Dan Ray