can i change the black background of an iphone app? - iphone

My app is structured like this, a single MainWindow with window backgroundColor to white(which doesn't appear anywhere anyway), and in this nib i have a UINavigationController which doesn't seems to have a backgroundColor.
Any view controller is added from code and made from code and they have a gray background.
What happens is that when i rotate the iphone and the views are rotating as well, i see a black background under my views. Can this be changed? It looks ugly especially if i have a photo that is rotating in the same time with my gray background.

You need to use the embedded view in the UINavigationView
When you are your UINavigationview Class :
self.view.backgroundColor = [UIColor greyColor];
Or any other color you want.

Change the backgroundColor of UIWindow in the file 'MainWindow.xib'

Related

UIPresentModalViewController view alpha is not being set

I want to present a view controller where I have one Background imageView.
Alpha for that imageview is 0.5 (want to add as semi-transperant black image so). But when I present that view controller that alpha doesn't work for view. That image entirely looks blackish, like alpha has not been even set.
This issue is there for iPad device only.
Please help me out.
Code:
ViewController1.m:
[self presentModalViewController:viewController2];
ViewController2.xib: (in nib I am setting below values no in code)
[self.view setBackgroundColor:[UIColor clearColor]];
[self.bgImageView setAlpha:0.5]; // this image is dark black, i want to display the
content of the screen which is behind this (viewController1.view), kind of semi-transperancy
I tried one more thing, this time i have removed imageView and set uiview bgcolor to black, opaque=NO, alpha=0.2 (in nib itself). So while animation of presenting it looks perfect. But when view has been placed it turns into alpha=1.0 (complete black)
Still there is no transparency where am i wrong over here.
Answer Is Here: There is some bug/limitation with ModalViewController so its better to go with addSubview for such situation
Try to write imageview.alpha = 0.5 after you present the modelviewcontroller and see what happens. Just give it a try.
EDIT:
1)Clean Build and Run
The image alpha you are trying to set, is it in viewcontroller that you are presenting from or is it in modalviewcontroller?
Answer Is Here: There is some bug/limitation with ModalViewController so its better to go with addSubview for such situation

iphone-uiview-background

I am new to iPhone development. I have one XIB file, the login page (a form).
Now I want to set the UIView background image.
When I supply an image from Interface Builder then there is no effect, and when I set it from the code then also no effect.
self.view.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:#"srk_ipad_Homepg.png"]];
I don't want to use a UIImageView because when I place an image, all my controls are hidden behind the UIView.
You can use UIImageView to set a background without harm, you just have to move it to the top of the view hierarchy. Look at this splashscreen view:
And this is the view's hierarchy tree:
This will prevent your controls from being covered.

Camera controls iphone 4 blocked by overlayview

In my camera function i have an custom overlayview, its is a square in the middle of the screen. Works all fine on the iphone 3gs but if I am launching it on my iphone 4 im getting troubles with the button to switch to the front camera, somehow it gets blocked by the overlayview. How to fix this?
Thanks in advance,
Dave
Hay, same problem, but another solution:
your_overlay.backgroundColor = [UIColor clearColor];
your_overlay.userInteractionEnabled = NO;
Your overlay view is probably sitting in front of the camera controls in the view hierarchy.
Try setting the backgroundColor of your overlay view to something like [UIColor greenColor] and running your app to see if it is showing up over the camera control. If you see that your app's new green background color is covering the camera control, it means that your view is blocking input events to the control, even when your view's background color is clear. You'll need to resize and reposition your view's frame so it doesn't cover the camera control.
When you're done, just get rid of the line in your code where you're setting the background color of your view to green.

Why will my custom background image work on the iPhone, but not iPad?

In my app delegate I am setting the view background of the view controller like this:
navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"iPhoneBackground.png"]];
And it works really well when i am running my iPhone app, but when I build it as an iPad app (its a universal application) the background is just gray.
The views that I am trying to get the image to set are simple drill down views of a uitableview. I just can't get an iPad image to show...
Thanks!
try to change the view's frame to be 1024x1024 before applying the background pattern
try setting tableView.backgroundView = nil

Annoying white border when rotating a view in iPad

When rotating a View from UIInterfaceOrientationPortrait to UIInterfaceOrientationPortraitUpsideDown on the iPad simulator, there is a white border along one side of the view (see diagram, lower left of the image). The white border shows only on one side, but not the opposite side. How can I prevent (hide) it? Thanks!
This is a guess:
It's possible that one of your views has a backgroundColor set to white, and it is completely covered by another view. During a rotation, perhaps floating point errors cause one border to show slightly through that edge.
To investigate this case, you can use the undocumented method [UIView recursiveDescription] to get a quick look at your view hierarchy (no need to submit code with that method, it's just for debugging). Once you know which views are near the bottom, you can print out their backgroundColors, or just set them all to [UIColor clearColor].
Also, I'm guessing you already know this one, but it can be useful to set window.backgroundColor = [UIColor clearColor] at the start of your code!
I had the same issue. I saw that in Interface builder autosizing for the view could not be enabled. I deleted the .xib and re-created it making sure product was set to "ipad" when creating the file (add new file in xcode).
You can also set the background color to nil. From the UIView documentation for backgroundColor:
The default value is nil, which results in a transparent background
color.
UIWindow inherits from UIView, so this works as well. Probably a good idea to use nil, in case [UIColor clearColor] isn't always the best way to do it.
The funny thing is, I have a project with no nibs, so I create the UIWindow in code, but the background color was white before I set it to nil. is the default background color of a programmatically created UIWindow white?