[翻译]  How to change color of detail disclosure button for table cell

[CHINESE]  如何更改表格单元格的详细信息披露按钮的颜色


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

我想更改表格单元格的详细信息披露按钮的颜色。提前致谢。

4 个解决方案

#1


13  

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

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

Your cellForRowAtIndexPath: will look something like the following,

你的cellForRowAtIndexPath:看起来像下面这样,

- (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];

        //...
    }

    //...
}

#2


13  

Change the tint of your tableview and cell will work too.

更改tableview的色调,单元格也会起作用。

#3


4  

You can change the Global Tint Colour. This will change the default colour to the colour you change in you app. This will change the colour of accessory button to the colour you select.

您可以更改全局色调颜色。这会将默认颜色更改为您在app中更改的颜色。这会将配件按钮的颜色更改为您选择的颜色。

#4


1  

As you got best code with you from simon: what i did is:

当你从simon那里得到最好的代码时:我所做的是:

UIButton *trackImageOnMap=[[UIButton alloc] initWithFrame:CGRectMake(420, 5, 40, 50)];
[trackImageOnMap setImage:[UIImage imageNamed:@"track_map_icon.png"] forState:UIControlStateNormal];
[trackImageOnMap setTag:iId];
[trackImageOnMap addTarget:self action:@selector(trackImageOnMapButtonTouched:)forControlEvents:UIControlEventTouchDown];
[trackImageOnMap setContentMode:UIViewContentModeScaleToFill];
[cell setAccessoryView:trackImageOnMap];

this implements some extra properties along with required one..

这实现了一些额外的属性以及必需的属性..


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号