【发布时间】:2011-05-03 21:23:42
【问题描述】:
就像标签栏一样,我想在UISegmentedControl 上显示徽章。因为我看不到 UISegmentedControl 的任何预定义方法,就像 UITabBar 可用的方法一样。
我曾考虑将徽章作为图像添加到其顶部,但也许有更好的方法。
【问题讨论】:
标签: iphone uitabbar uisegmentedcontrol badge
就像标签栏一样,我想在UISegmentedControl 上显示徽章。因为我看不到 UISegmentedControl 的任何预定义方法,就像 UITabBar 可用的方法一样。
我曾考虑将徽章作为图像添加到其顶部,但也许有更好的方法。
【问题讨论】:
标签: iphone uitabbar uisegmentedcontrol badge
Here 是我用来在各种事物上绘制徽章的小型第三方库。这很不错。例如,更改徽章的颜色以匹配我的设计很简单。
一旦你把这个类引入你的项目并将它包含到你的视图控制器中,你就可以:
CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:@"Badge 1"];
...然后将 customBadge1 添加为您要标记的任何东西的子视图。
【讨论】:
我今天遇到了这个问题,所以我整理了一个 UISegmentedControl 子类,它允许您轻松地在每个段上设置徽章编号。
使用起来很简单:
[segmentedControl setBadgeNumber:1 forSegmentAtIndex:0];
屏幕截图、文档和源代码位于https://github.com/dave-thompson/MESegmentedControl。
【讨论】:
没有徽章属性或方法 - 与标签栏不同。如果你想这样做,你只需要在上面放一个自定义图像。您可以对分段控件进行子类化并创建一个为您执行此操作的函数。
【讨论】: