Bill
Bill

Reputation: 45

How to Add a badge to my ImageView in ios?

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

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?

The table view cell's image

Upvotes: 0

Views: 4085

Answers (1)

Andriy
Andriy

Reputation: 1894

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];

Upvotes: 1

Related Questions