Change background Color in ios - ios

i want to change my application background change. My view name is topNavVw for change my application background color i used this code
topNavVw.backgroundColor = [UIColor blackColor];
but it's not working .
Thanks in advance

You have to call
self.view.backgroundColor = [UIColor blackColor];
in viewDidLoad, in the Controller class that you want to appear black.
If you want a specific view/button/label to have a black background then it is the same,
myView.backgroundColor = [UIColor blackColor];
If it still doesn't work, use the view hierarchy debug (the button just before the arrow on the bottom of the screen, in the separation of the debug screen and code screen). There you will be able to see all your views and maybe you'll notice that your black view is behind another view that is not black.

Related

How to skin the arrow on PopoverPresentationController

I have a PopoverPresentationController, which needs to have black background , I applied background color but the arrow doesn't get skinned or coloured, attached is the image how it looks . POPController has tableview in it .
We are unable to remove arrow for popover controller. If you don't need arrow you need to customise your own view. If you want to change the background color
popOver.popoverPresentationController.sourceRect = btn.bounds;
popOver.popoverPresentationController.sourceView = btn;
popOver.popoverPresentationController.backgroundColor = [UIColor redColor];

TintColor Changing on Popover Push

I'm setting the tint color of a window to an arbitrary color, then trying to over-ride this on a per-button basis, but it appears that the buttons revert to the window tint color whenever there is a segue applied on them.
Setting tint color in didFinishLaunchingWithOptions:
self.window.tintColor = [UIColor redColor];
and then my two buttons in viewDidLoad:
[self.button1 setImage:[[UIImage imageNamed:#"711-trash"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
self.button1.tintColor = [UIColor purpleColor];
self.button2.tintColor = [UIColor blueColor];
where button1 is a custom type button and button2 is a system type button.
When the popover first presents, the two buttons are tinted purple and blue. But when the segue view controller is pushed, the popped, the two buttons switch to red. Is there any way to prevent this?
EDIT:
I've tried reproducing your code like this:
However everything worked as expected:
So I agree with #user3779315, possibly you are setting the buttons' tint color somewhere else. Btw, additional code of your project would help to clarify the issue :-)

How to set clearColor for UIPopover View?

I need to set UIPopover background color to clearColor. But rest of all colors are working fine with below code:
myPopover.backgroundColor = [UIColor greenColor];
but when I set clearColor, there is a white background instead of transparent.
Can any one help me. Thanks in Advance!
If what you're talking about is a UIPopoverController, then try setting the background color to its content view controller's view.
myPopover.contentViewController.view.backgroundColor = [UIColor clearColor];
Also, check this SO post about custom popover backgrounds.

UISearchDisplayController TableView goes black after erasing text

I have a UISearchDisplayController that goes black after erasing search-text.
These pictures explain my issue:
Add an a to the searchbar
Removes the a from the searchbar
I tried these settings in ViewDidLoad, but it's not working.
self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor clearColor];
self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor clearColor];
Actually the searchResultsTableView is not shown when the search bar is empty. Instead a semi transparent view is shown so that you can see the underlying view (usually the view of the VC that invokes the search). In your case I guess the underlying view is black so it doesn't matter that the search view is semi transparent :)
Setting its background to white color should do the trick.

PageControl backgroundColor when used in UIPageViewController

I'm trying to implement a simple tutorial using UIPageViewController in iOS7. I implement all methods in UIPageViewControllerDataSource and it gives me a UIPageControl. Everything works except that the pageControl's background is not transparent so it blocks part of the other views behind it.
I try to change the pageControl's appearance with the following code
pageControl.backgroundColor = [UIColor greenColor]; //works, background is green
pageControl.backgroundColor = [UIColor clearColor]; //not working, background is black.
//updates
It turns out that the black color is the background color of the PageControl's layer. And this Page Control layer is not on top of my own ViewControllers that I used for pages. They are in parallel.So no matter how I modify its colors, I cannot get my ViewControllers to take the full screen.
Is there an easy way to move the PageControl on top of my ViewControllers?
It could be the background of the parent view. I had a similar situation where the background color was actually the background of my parent control, not my own. Here is a tool I use that helped me narrow this down : http://www.sparkinspector.com. Here is another tool that does the same thing : http://revealapp.com.
Also one more thing - not sure if this would apply to your case, but it could be the background layer that might need its color set
CALayer *layer = self.layer;
[layer setBackgroundColor:[UIColor clearColor]];
if you set something to be clear color, the background color then depends on whatever is on the background, the view the page control is in (usually a uipagecontrol) has no background, and this is why you're seeing it as black.

Resources