开发者

How to change color of detail disclosure button for table cell

I want to c开发者_Python百科hange the color of detail disclosure button of a table cell. Thanks in advance.


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

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

        //...
    }

    //...
}


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


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.


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

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..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜