How to Display Count beside a category in UITableViewCell?
How can we display #of items in a category displayed in a particular UITableViewCell? For example, in iPhone mail app, they show # of new emails in each account..开发者_运维问答
Thanks Jignesh
Simply customize your UITableViewCell
(see here) and add a custom UILabel
as a subview of your cell so it displays on the right.
If you want to make this UILabel to look like the ones in Mail, this is quite simple, as you may try sthg like this:
countLabel = [[[UILabel alloc] initWithFrame:CGRectMake(140,10,60,24)] autorelease];
countLabel.textColor = [UIColor whiteColor];
countLabel.layer.backgroundColor = [UIColor grayColor].CGColor;
countLabel.layer.cornerRadius = countLabel.bounds.size.height / 2;
countLabel.masksToBounds = YES;
[cell.contentView addSubview:countLabel];
countLabel.text = [categoryItems count];
(Note: to use the layer property of UILabel, don't forget to add the QuartzCore framework and #import <QuartzCore/QuartzCore.h>
)
Check out the TDBadgeCell
library on Github.
精彩评论