Can someone help me create an index/count button for a UITableView, like this one?
iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpgIs there an Apple example, or other tutorial? Thanks, Jordan
Can someone help me create an index/count button for a UITableView, like this one?
iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpgIs there an Apple example, or other tutorial? Thanks, Jordan
Wow... aaa... ok... I ve got an easier way:
#import <QuartzCore/QuartzCore.h>
.....
UILabel *label = [[UILabel alloc] initWithFrame:
CGRectMake(cell.contentView.frame.size.width - 50, 0, 35, 35)];
label.layer.cornerRadius = 5;
label.backgroundColor = [UIColor blueColor]; //feel free to be creative
label.clipToBounds = YES;
label.text = @"7"; //Your text here
[cell.contentView addSubview: label];
[label release];
Basically, you re making a UILabel with rounded corners using the QuartzCore framework - don t forget to include it. Extra note: it only works on OS > 3.0.
You need to create a custom view, and then draw the oval and number in manually. Finally, assign that custom view as the accessory view of the cell. Here s the drawing code, using Core Graphics. It s not too tricky:
CGRect bounds = self.bounds;
CGContextRef context = UIGraphicsGetCurrentContext();
float radius = bounds.size.height / 2.0;
NSString *countString = [NSString stringWithFormat: @"%d", _count];
if (_count < 100) bounds = CGRectMake(5, 0, bounds.size.width - 10, bounds.size.height);
CGContextClearRect(context, bounds);
CGContextSetFillColorWithColor(context, _color.CGColor);
CGContextBeginPath(context);
CGContextAddArc(context, radius + bounds.origin.x, radius, radius, M_PI / 2 , 3 * M_PI / 2, NO);
CGContextAddArc(context, (bounds.size.width + bounds.origin.x) - radius, radius, radius, 3 * M_PI / 2, M_PI / 2, NO);
CGContextClosePath(context);
CGContextFillPath(context);
[[UIColor whiteColor] set];
UIFont *font = [UIFont boldSystemFontOfSize: 14];
CGSize numberSize = [countString sizeWithFont: font];
bounds.origin.x += (bounds.size.width - numberSize.width) / 2;
[countString drawInRect: bounds withFont: font];
I have another post which resulted in this SELECT DISTINCT a.ArticleID, COUNT(*) AS KeywordMatch, a.Headline, a.ShortDescription, a.CategoryID, a....
I m trying to get the percentage of each video I have in my database based on its view count against all other videos. I m then trying to display all the videos from highest view count to lowest, ...
I have posts, votes, and comments tables. Each post can have N yes votes , N no votes and N comments. I am trying to get a set of posts sorted by number of yes votes. I have a query that does ...
I have a page where I am running an initial SQL query to get a list of subjects, then I loop over this query and run two additional queries for each record returned from the original subjects query (I ...
Can someone recommend a function that can allow me to count and return the number of items in a list? library(stringr) l <- strsplit(words, "a") if(# number of items in list l < 1) ...
My Current query is: SELECT DISTINCT DATE(vote_timestamp) AS Date, COUNT(*) AS TotalVotes FROM `votes` WHERE vote_target_id= 83031 GROUP BY DATE(vote_timestamp) ORDER BY DATE(vote_timestamp) DESC ...
I always forget how to do things like this. I have a database table with birthdates and I want to find out how many people have the same age. I m trying: SELECT TIMESTAMPDIFF( YEAR, birthdate, ...
Can someone help me create an index/count button for a UITableView, like this one? iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpg Is there an Apple example, or other ...