How do I make UITableViewCellAccessoryDisclosureIndicator visible in black background?

做~自己de王妃 提交于 2021-01-27 03:53:51

问题


cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

in this method

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

but I can only see it when I select that cell otherwise it's not visible.and it work perfectly when background is white. I am sure that I need to set a property, but I don't know which property I need to change to make this thing work.

thanks in advance.

cheers.


回答1:


It would appear that the disclosure indicator is a gray, high-alpha image, so overlaying that over a black background makes it invisible. If you want to do this, you'll need to add your own UIImageView to the cell's contentView.




回答2:


I ran into this same issue, and just create a UIImageView out of a UIView’s imageWithName @"AccDisclosure.png" using the following hastily mocked-up graphic which you're free to copy: http://thinkingman.com/db/downloads/AccDisclosure.png (if you just click that link, you'll probably see nothing, as it's a white image with a transparent background, but if you save it and view against a dark background, you'll see the alpha).




回答3:


The following code allows me to set the background color of the arrow tip in a table row:

@property (nonatomic,retain) UILabel *backgroundLabel;

UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor orangeColor]; 
self.backgroundLabel = label;
[self.contentView addSubview:label];
[label release];

CGRect labelRect = CGRectOffset(contentRect,0, 0);
labelRect.size.height = contentRect.size.height - 1; // show white line
labelRect.size.width = contentRect.size.width + 50; // cover arrow tip background
backgroundLabel.frame = labelRect;    
backgroundLabel.highlightedTextColor = [UIColor whiteColor];



回答4:


I made a solution where I added an ImageView with addSubView in the normal fashion, with an image that was not black (in my case, a grey filled circle) at the position where the accessory appears.

That allows the arrow to be seen and still have a dark/black table cell background color.

Maybe not the most kosher solution, but it makes the arrow visible, and I get notified of accessory clicks without subclassing or writing lots of code.



来源:https://stackoverflow.com/questions/249010/how-do-i-make-uitableviewcellaccessorydisclosureindicator-visible-in-black-backg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!