如何在 ios 中为我的 ImageView 添加徽章?

编程入门 行业动态 更新时间:2024-10-25 16:17:52
本文介绍了如何在 ios 中为我的 ImageView 添加徽章?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

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/Marxon13/M13BadgeView pod 库.只需将徽章视图添加到单元格图像中,如下面的示例所示:

The easiest way is to use https://github/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屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 11:05:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:徽章   中为   如何在   ios   ImageView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!