简体   繁体   English

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

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

I want to change the color of detail disclosure button of a table cell. 我想更改表格单元格的详细信息披露按钮的颜色。 Thanks in advance. 提前致谢。

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

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

        //...
    }

    //...
}

You can change the Global Tint Colour. 您可以更改全局色调颜色。 This will change the default colour to the colour you change in you app. 这会将默认颜色更改为您在app中更改的颜色。 This will change the colour of accessory button to the colour you select. 这会将配件按钮的颜色更改为您选择的颜色。

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.. 这实现了一些额外的属性以及必需的属性..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM