UIPickerVIew cells show dark background - iphone

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

Related

Matching UITableView and UIViewController background colours

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.

NSTabView Background Color

I have a window controller with blue background color
The background color of all children view controllers work fine with blue background just like their parent window controller, except NSTabView of NSTabViewController, which draws with the original gray background
I am not sure why it does not inherit the background color, or why it is not transparent
Anyway, to solve the issue, I tried the following
(1)
I tried editing the CLayer background
tabView.layer?.backgroundColor = NSColor.blue.cgColor
I tried putting that code everywhere, and the only time it worked is when I accessed the CLayer from a tabViewItem inside its viewWillAppear function or viewDidAppear or viewWillLayout, but the problem is that this code does not work until I select another tab... i.e. when the tabViewController is shown at the beginning, the initial view background color is grey, and does not change to blue until I select another tab!
From my understanding, the tabView is drawn after its child viewDidAppear, that's why it overcame the blue color order, and when another tab is selected, the viewDidAppear function is called again changing the color to blue (since the tabView` is already drawn)
(2)
I tried to change drawsBackground value to false
when the tabviewcontroller is shown, the background is just like what its windows is, blue, but as soon as I choose another tab, black residue are left from the previous tabviewitem controls
any idea how to solve this problem is much appreciated!
I solved this by adding a Custom Box to the initial tab with the required background color, and resized it to the size of the view
In the rest of tab views, I added this line to viewWillAppear function
tabView.layer?.backgroundColor = NSColor.blue.cgColor
The custom box feels like a hack but is the only way around I could come up with
An alternative solution is to place a custom NSBox behind the NSTabView with the correct size and background color. No further code needed, as long as all tabs feature a transparent background.

Making font colour negative to the background. iOS

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!

Scrolling png with text & alpha on top of a static UIImageView

I have a view controller that has a view structure as follows:
FilesOwner
FirstResponder
View
ImageView (.jpg)
ScrollView
ImageView (.png)
The text in the innermost imageview has white text and clear (alpha) all around. I want to scroll the innermost imageview, and see the background image (the .jpg) behind it.
Its not working. Its acting like the scrollview background obscures the underneath .jpg. I say this because if I change the background color of the scrollview, that's what I see i.e. if I set it black, I see black behind my .png, if I set it white, I see white. If I change the alpha of the scrollview that doesn't seem to work either. The one other thing I tried was unchecking drawing: Opaque, but that doesn't get it either.
Try setting the alpha value of your scrollviews background color to 0 (not the alpha value of the scrollview itself). The scrollview should be set to not opaque.
(didn't try, just guessing...)

Custom UITableViewCell always black unless set to anything but clear

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)