Number of rows in a UITableView, such as an iOS Mail app

How do you add counters inside a UITableView UITableViewCell like iOS Mail app?

enter image description here

+6
source share
3 answers

In addition to DDBadgeViewCell (@micpringle mentioned), also TDBadgedCell .

I tried both and found TDBadgedCell to fit my needs more, because it puts icons on top of the cell text, not under it, which means the icons are visible even for cells with long texts.

The project also seems (at least for now) more active than DDBadgeViewCell. (At the same time, there seems to be an error in the non-ARC version of TDBadgedCell).

+1
source

Create a custom UITableViewCell, place the labels where you want (name, subtitles, score, everything you need). I highly recommend Matt Gallaghers, a custom UITableView code - it takes a lot of headaches to deal with custom strings. You will need to follow Matt Gallaghers steps to configure the cell.

To get a label with a label as close as possible to your example (mail.app), you need to set UILabel backgroundColor gray (or whatever color you want), textColor to white, and layer.cornerRadius to something equal to half the height of the label (if mark 20 is high, angleRadius should be 10). This will result in a UILabel with white text, gray background, round corners. Please note that this is not the most efficient way to do this, but Apple has not put in a video recording of the WWDC session, where they better explain the effective method (I skipped this session).

0
source

The easiest solution would be to set UILabel as an accessoryView or use a custom subclass of UITableViewCell that could be designed using IB.

I would recommend creating simple rounded UIView and a UILabel as a subset in it. I would probably create a subclass of UITableViewCell for content management.

Definitely the easiest way would be to use a ready-to-use class like TDBadgedCell

0
source

Source: https://habr.com/ru/post/891251/


All Articles