My custom UITableViewCells always have a black background unless I set the background of the UITableView to clear.
However I want to set the background colour to another colour and as soon as I do the cells turn black (even though the background of the control does change)
Related
I have a UITableView in a UIViewController. I'm trying to set both backgrounds to the same colour but despite both background having identical RGB values, they end up displaying a slight mismatch - see image below.
I have tried setting the UITableView background colour to clear as well but this has no effect either.
Any ideas why this might be occurring?
Make sure to set the background color of tableView like below
I would also recommend you to debug via Debug View Hierarchy in XCode to see which view has what color.
I have a UIPickerView which I can't get to show correctly. The background of the cells in the picker shows a dark shade or completely black, depending on the transparency (alpha channel) set on the picker (See images below). The first image shows an alpha of 1, and the second one shows it at 0.7. Delegate and data source are set, as the second image shows. I am not returning custom views for the cells, just returning a title. Also setting the alpha to 0 will not work because the background is invisible, but so is the entire picker.
Anyone experienced this before? Thanks
I want to make text in a UILabel appear of a color negative to that background it is placed on.
I am placing the label on a web view, and I want that label to be always of a negative colour to the background so that no matter what colour (when web view is scrolled) is exactly below the text, it is always visible in a negative colour.
Thank you.
I don't recommend you to do that because the scrolling part of the webView won't be smooth with all those calculations in it. So I suggest you to set a background ImageView to your label and set a image with a negative color to your font color to that ImageView
An alternative would be setting the shadowColor to the opposite of the textColor (for example, white and black, respectively), ensuring that you'll always be able to pick out the text regardless of the web view's background color.
Don't forget to set the shadowOffset too!
How do I apply a tint to the background of a UITableView using the grouped style? The standard "color" used ([UIColor groupTableViewBackgroundColor]) is tinted blue; I want a green tint instead.
This uses a pattern rather than a true color. I just want to tint that pattern to match the colors I'm using elsewhere, not replace it with a solid color.
The easiest way is to make a screenshot of the default grouped tableview background and crop it so that its size is 7x1 pixels (that's enough to tile it). Adjust the tint color (hue, saturation, brightness) in your favorite image editor and use the resulting image as a pattern color via +colorWithPatternImage:, e.g.:
myTableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"GreenStripes.png"]];
You could probably do this somehow with coregraphics by drawing the grouped tableview color to a context, tinting it, and then using a bitmap of the context as a repeated background for your tableview somehow. I couldn't tell you just how to do that, though.
Why not just do the tinting in Photoshop or GIMP or something and save it as a 32x480 (or whatever res you need) image, and use that image as your tableview's background image. To get the initial pinstripe image, just make a fullscreen view with that as the background color.
A third option would be to place a translucent green view above another view with the grouped tableview background color. Don't know how well that would work, though.
A UITableViewCell reflects two distinct states: Highlighted and Selected.
For me, they sound identical so what exactly are the differences?
Highlight happens on touch down.
Selected happens on touch up, followed by the call to didSelectRowAtIndexPath:. In a standard UITableView, there is usually a small delay between the highlight and the select.
From appearance point of view:
Selected Cell:
The selection affects the appearance of labels, image, and background. When the selected state of a cell is set to YES, it draws the background for selected cells with its title in white.
The background will be drawn based on selectionStyle & selectedBackgroundView values. I could not really see any white titles as Apple documentation mentioned. I just see the background changes as expected.
Highlighted Cell:
The highlighting affects the appearance of labels, image, and background. When the highlighted state of a cell is set to YES, labels are drawn in their highlighted text color (default is white).
Note that for highlighting to work properly, you must fetch the cell’s labels using the textLabel and detailTextLabel properties and set each label’s highlightedTextColor property; for images, get the cell’s image using the imageView property and set the UIImageView object’s highlightedImage property.
Again I don't really that see that the default highlighted text color is white.
So I conclude that selected cell appearance affects the background of the cell while the highlighted cell affects the labels text colors as well as the image (if highlightedImage property is set)