带有徽章编号的 UISegmentedControl
就像标签栏一样,我想在 UISegmentedControl
上显示徽章。因为我看不到 UISegmentedControl
的任何预定义方法,就像可用于 UITabBar
的方法一样。
我考虑过将徽章作为图像添加到其顶部,但也许有更好的方法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里是我用来在各种事物上绘制徽章的一个小型第三方库。非常漂亮。例如,更改徽章的颜色以匹配我的设计是微不足道的。
将此类引入项目并将其包含到视图控制器中后,您可以:
...然后添加 customBadge1 作为您要标记的任何内容的子视图。
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:
...and then add customBadge1 as a subview of whatever thing you're badging.
我今天遇到了这个问题,所以我整理了一个 UISegmentedControl 子类,它允许您轻松地在每个段上设置徽章编号。
使用它非常简单:
屏幕截图、文档和源代码位于 https://github.com/dave-thompson /MESegmentedControl 。
I had this problem today, so I've put together a UISegmentedControl subclass which allows you to easily set badge numbers on each of the segments.
Using it's as easy as:
Screenshot, documentation and source code are at https://github.com/dave-thompson/MESegmentedControl .
与选项卡栏不同,没有徽章属性或方法。如果您想这样做,您只需在其上放置一个自定义图像即可。您可以对分段控件进行子类化并创建一个函数来为您执行此操作。
There is no badge property or method - unlike the tab bar. If you want to do this you will just have to put a custom image over it. You could subclass the segmented control and create a function that does this for you.