如何在 ios 中为我的 ImageView 添加徽章? [英] How to Add a badge to my ImageView in ios?

查看:42
本文介绍了如何在 ios 中为我的 ImageView 添加徽章?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在开发一款聊天应用.我在处理传入消息时遇到了麻烦.

I am recently working on a chat app. I have a trouble here about handling the incoming messages.

我有一个 tableview,它显示了我拥有的所有对话框.收到新消息后,我想在该单元格的图标上添加一些数字(类似于应用程序上的徽章).我尝试向左上角的单元格添加子视图?我对此不太确定.我该怎么做才能实现这一点?

I have a tableview which shows all the dialog that i have. Once i receive the new messages i want to add some numbers (which is similar to the badges on the app) on the icon of that cell. I try to add a subview to the cell at the upper-left of the corner? I am not quite sure about this.What can i do to implement this?

表格视图单元格的图像

推荐答案

最简单的方法是使用 https://github.com/Marxon13/M13BadgeView pod 库.只需将徽章视图添加到单元格图像中,如下面的示例所示:

The easiest way is to use https://github.com/Marxon13/M13BadgeView pod library. Simply add badge view to a cell image like in sample bellow:

M13BadgeView *badgeView = [[M13BadgeView alloc] initWithFrame:CGRectMake(0, 0, 24.0, 24.0)];
badgeView.text = @"1";
[cell.imageView addSubview:badgeView];

这篇关于如何在 ios 中为我的 ImageView 添加徽章?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆