PageControl backgroundColor when used in UIPageViewController - ios

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.

Related

Strange behaviour of tableView's background when swiping back in a ViewController using UIVisualEffectView

I use UIVisualEffectView as my tableview's backgroundView, just for the blur effect, everything is fine except when I begin to swipe the current view back to previous view, the tableview's background immediately become black, not blurred anymore.
UIVisualEffectView is actually a hack in the Apple framework. It's not an overlapping layer, it completely replaces the layers behind itself by processing them. Try to add this effect behind the table and clear background of table view.
In viewDidLoad method
self.tabelView.backgroundColor = [UIColor clearColor];
In cellForRowAtIndexPath method
cell.backgroundColor = [UIColor clearColor];

Change background Color in 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.

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.

Pattern to fill the entire screen

Every screen of my app has a common tint. Its not a background. Its a pattern that fills the entire screen and it is top of all the views. You can see the pattern flow continuously from one view to another inside the same screen. And it neither obscures other elements nor participate in event handling.
I tried implementing it with this code in my ViewController.
UIColor* texture = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Texture.png"]];
UIView* tintView = [[UIView alloc] initWithFrame:self.view.bounds];
[tintView setBackgroundColor:texture];
[tintView setAlpha:0.5];
[self.view addSubview:tintView];
But it doesn't pass on touches to the views behind it.
tintView shouldn't participate in any event handling. Rather it should let other elements behind it, handle the events like they do it normally.
Other way of doing it is set this as a background of the view property of a UIViewController and set a common alpha for all other subviews of view to show the pattern behind. That will be redundant in most ways.
Any better way of doing this?
Make your tintView a subclass of UIView and implement the hitTest:withEvent: method, returning nil. This will make your view transparent to touches. Or set userInteractionEnabled to NO.
Set the background color with a Textured image
UIImage *bgimg = [UIImage imageNamed:#"Texture.png"];
self.view.backgroundColor = [UIColor colorWithPatternImage:bgimg];

UIWebView over an UIView gets UIView alpha value

I'm developing an iOS 4 application.
I have a main view that contains another UIView, named shadowView, with an UIWebView inside. This shadowView has black as background color and alpha = 0.3f.
My problem is that UIWebView inherits shadowView alpha value, and I don't want that, I need UIWebView has alpha = 1.0.
Do you know how can I do that?
If I understand your question, you have added a UIWebView to a UIView which has an alpha of 0.3.
On iOS, any sub-views inherit their parent views alpha values (or rather, the parent view 'masks' the sub-view).
It sounds as if you want your shadowView to have a translucent background: rather than setting the alpha of the view, you should instead do this:
[shadowView setAlpha:1.0];
[shadowView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.3]];`
...which will (as long as your view isn't set to be opaque) give you a nice translucent background and allow your sub-views to not appear transparent as well.

Resources