如何更改表格单元格的详细信息披露按钮的颜色 [英] How to change color of detail disclosure button for table cell

查看:172
本文介绍了如何更改表格单元格的详细信息披露按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改表格单元格的详细信息披露按钮的颜色。在此先感谢。

I want to change the color of detail disclosure button of a table cell. Thanks in advance.

推荐答案


您必须创建自定义 UIButton 并将其设置为单元格的 accessoryView

You have to create a custom UIButton and set it as cell's accessoryView.

您的 cellForRowAtIndexPath:会看起来像什么如下所示,

Your cellForRowAtIndexPath: will look something like the following,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    //...

    if (cell == nil) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];

        UIButton *myAccessoryButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
        [myAccessoryButton setBackgroundColor:[UIColor clearColor]];
        [myAccessoryButton setImage:[UIImage imageNamed:@"my_red_accessory_image"] forState:UIControlStateNormal];
        [cell setAccessoryView:myAccessoryButton];
        [myAccessoryButton release];

        //...
    }

    //...
}

这篇关于如何更改表格单元格的详细信息披露按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆