Matching UITableView and UIViewController background colours - swift

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.

Related

Button's background on ios7 is squeezed, ios6 ok

I just updated to XCode 5. Buttons in my app look OK in IB and on iOS 6 device, but on iOS 7 device they look like this (they should cover the whole black space):
I have images for both non-retina/retina.
I have no idea what to do, because I didn't change anything in code or IB.
EDIT:
Now I found out, if I change type of button from custom to system and set its background instead of its image, I get the correct size but I get some strange shadow over it.
EDIT2:
Now I set button's tint color to "clear color" and everything seems ok (shadow disappeared). Still not sure what has changed in iOS 7 related to this.
The Human Interface Guidelines specifically outline how system-style UIButtons work by default. It explains that a system button:
Has no border or background appearance by default ...
Supports custom decoration, such as a border or background image (to
add a custom appearance, use a button of type UIButtonTypeCustom and
supply a custom background image).
However the UIButton HIG page provides a little more information, specifically:
If you do not explicitly set a tint color, the button will inherit its superview’s tint color.
This explains why, after changing your button to UIButtonTypeSystem, you suddenly have to reset (remove) the tint colour. In iOS7, (almost) everything has a tint colour. A UIButtonTypeSystem is more appropriate for your needs now in iOS7 (a bit of a pain if there's a lot to manually change though...)
As to why the buttons shrink in iOS7... I agree with #Joseph's comment regarding UIViewController view frames in iOS7. Likely you have some set relation for the size of the buttons that does not play nicely when the ViewController's frame changes in iOS7 (see this SO question for discussion). As advised there, check out the iOS7 transition guide to see if anything you're doing in IB is going against the new iOS7-grain.
[button setBackgroundColor:[UIColor colorWithRed:(255.0/255.0) green:(180.0/255.0)];.
This is the right code for background, and if you are use image then use
[UIImage imageNamed:#".png"];

UIPickerVIew cells show dark background

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

How do I implement a UITableView that can scroll over a background

I'm trying to implement a tableview where the tableview cells can scroll over a background similar to the way the facebook Poke app works. Are they using a custom uitableview or implementing the interface with a uicollectionview?
Create an UIImageView with your background image. Then set the table view's backgroundView property to the image view. This approach works well with a plain style table.
You can give the table view and the cells a clear background color (in IB or code), and give the window a background color -- you can use colorWithPatternImage:, if you want an image in the background.

UISearchBar background fading in and out when segue push animates

I created two views that has its transition controlled by a navigation view controller. I have a UIView which contain a UISearchBar. The UIView is then set as the navigation bar's titleView in the first view.
Now, the problem is, whenever I go from the first view to the second view, I can see a light background behind the UISearchBar fading in and out.
I have did a bit of troubleshooting of my own and found that the background belongs to the UISearchBar and not the UIView that contains it. I have also tried many codes to make the UISearchBar background transparent, but none of the codes actually makes it transparent.
Edit: I did a bit more fiddling and found that the colour fading in and out is the colour from the style/tint of the UISearchBar. So if I change the tint to black, it'll darken instead. The only way I see I can fix this is to turn the background of the UISearchBar's alpha to 0, but I can't find any code that can change the alpha of a UISearchBar in a UINavigationBar.
Edit: I really can't find any code to turn the background tint of the UISearchBar to be alpha 0. Does anyone have a workaround or an alternative solution to this?
I realised that the bar is actually the scope bar's background. I'm not sure why it still showed up even though I disabled it. My solution was to set the background image as a transparent image.
[self.searchBar setScopeBarBackgroundImage:[UIImage imageNamed:#"transpixel.png"]];

UIButton Background Images appear lighter in Simulator than in IB

Just put a background image on a button. The looks fine in IB but when I build and run the project in Simulator the bg is noticeably lighter. Anyone know why could be?
Thanks!
It might be the case that the alpha value for your view or one of its superviews in less than 100% (value 1.0). I've seen cases where a superview had low alpha, but the subviews appeared solid in Interface Builder, while of course they were transparent or translucent when I actually ran the app.