How can I customize the accessory disclosure image in a UITableViewCell?

前端 未结 9 606
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 15:55

I would like to use a custom version of the standard disclosure accessory image in my UITableView. How can I do this? I\'m hoping that sub-classing UITableViewCell is not ne

9条回答
  •  攒了一身酷
    2020-12-07 16:17

    I ran into the same problem as Greg--the accessory view doesn't track (if you use an UIImageView)

    I solved it like this:

    UIImage * image = [ UIImage imageNamed:@"disclosure-button-grey.png" ] ;
    UIControl * c = [ [ UIControl alloc ] initWithFrame:(CGRect){ CGPointZero, image.size } ] ;
    
    c.layer.contents = (id)image.CGImage ;
    [ c addTarget:self action:@selector( accessoryTapped: ) forControlEvents:UIControlEventTouchUpInside ] ;
    cell.accessoryView = c ;
    [ c release ] ;
    

提交回复
热议问题