开发者

How do I access the image file for the UITableViewCellAccessoryDisclosureIndicator?

I'm trying to make a custom UITableViewCellAccessoryDisclosureIndicator that is a little bit larger than the normal indi开发者_运维技巧cator and is a different color. I was wondering if anyone can tell me how to access the file where both the indicator and the highlited indicator is?

Or if there is way to accomplish this programmatically, I'd be interested in hearing that as well. Thanks!


You can't access the disclosure indictor directly since it is a system type, but you can set your own custom indicator by creating a custom view and setting it with the accessoryView (or editingAccessoryView) property.


I believe most common UIKit elements are in UIKit.framework/Other.artwork. .artwork files are essentially just raw pixel data in BGRA order — to do anything useful you'll generally need image offsets/sizes.

Instead, the easiest way to get random images from the SDK is generally to render the layer in a bitmap context (or grab CALayer.contents if it's just a CGImage) and write it out as a PNG. First you have to find the right layer — for a table cell, I'd breakpoint -tableView:didSelectRowAtIndexPath:, call [tableView cellForRowAtIndexPath:indexPath] to get the cell, and look at its subviews until I found something of about the right size for a disclosure indicator. Then, just call something like

-(void)dumpLayerAsPNG:(CALayer*)layer
{
  UIGraphicsBeginImageContextWithOptions(layer.bounds.size, 0, 0);
  [layer renderInContext:UIGraphicsGetCurrentContext()];
  UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  NSData * imgData = UIImagePNGRepresentation(img);
  NSString * docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
  NSString * filename = @"foo.png";
  [imgData writeToFile:[docsDir stringByAppendingPathComponent:filename] atomically:NO];
}


Actually, I think I phrased the question wrong. I was basically just looking for the image file of the disclosure indicator so I could edit it. I found this: http://www.google.com/imgres?q=UITableview+disclosure+indicator&um=1&hl=en&sa=N&biw=1280&bih=577&tbm=isch&tbnid=bmE9FbJw6SMJJM:&imgrefurl=http://www.tech-recipes.com/rx/3357/iphone-programming-set-uitableview-accessory-arrow-style/&docid=T9TugtqFzb-3bM&w=50&h=50&ei=7m2PTunuAq-DsALk2ISvAQ&zoom=1&iact=rc&dur=374&page=1&tbnh=50&tbnw=50&start=0&ndsp=11&ved=1t:429,r:1,s:0&tx=20&ty=12

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜