Setting modal image view? - iphone

In the Epic Win iPhone app, they seem to have some sort of image view in the front of another view. How does one implement this?
Example:

All you have to do is to create a new view and add it to the window. You can do that like this:
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
overlayView.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];
[overlayView addSubview:<#imageView#>];
[self.view.window addSubview:overlayView];
[overlayView release];
Let me know if that works for you.

From above example it seems that they just added Imageview on self.view and they decrease alpha of self.view. It doesn't seems something triky.

That's very simple and there are probably a few ways to do it.
The simplest is probably to just add an image view as subview of the window.

Check out this CustomAlert Class. Shows you how to change the background of a UIAlertView.

Related

how can i make uiview on the Uinavigationbar

I am doing one iphone app. In this app i want to disable the back navigationleftbarbutton. I have used this below code for disable the navigationleftbarbutton but it is not working. Now i have created one view and i have added in uinavigationbar. But now i want to make that view in transparent view. And also how can i remove my customview(myview1) from the navigationbar. I have attached my code. please some body help me to solve my issue.
Disable Code:
self.navigationItem.leftBarButtonItem setEnabled:NO];
And This is my customview Code:
myview1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
myview1.backgroundColor = [UIColor redColor];
button = [[UIBarButtonItem alloc]initWithCustomView:myview1];
self.navigationItem.leftBarButtonItem = button;
How can i make myview is transparent view. And how can i remove mycustomview(myview1) from navigationbar. Thanks in advance.
you can hide navigation back button by writing code below:
self.navigationItem.leftBarButtonItem.hidden = YES;
and your view ie myview can be transparent by changing alpha value of the view
[myview setAlpha:0.3]; //alpha value ranges from 0 to 1
By settign alpha value 0.0 makes view transparent and increases transparency as u increases alpha value

Is it possible to change tableView.backgroundView frame?

I want to put my table view background below the nav bar. When I try to change frame nothing happens..
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, -100, 320, 480)];
imageView.image = self.theme.bgImage;
[self.tableView setBackgroundView:imageView];
In the docs it says:
A table view’s background view is automatically resized to match the
size of the table view.
So I think it's alway resized again by the framework.
Add UIImageview as subview to view and set appropriate image.Place imageview behind tableview. Make tableview background nil. Then try to change frame. This may help you.

Add UITextField to cameraOverlay

Hi all I am trying to add a UITextField to my cameraOverlay. I am getting it to show up on my camera view, but it is not editable. Its not responding at all. What approach do I need to take to get it to repsond?
I have looked at this questions, but do not understand how to set a transparent View Controller on top of my cameraOverly.
Suggestion for camera overlay
Thanks in advance!
Steps should be:
Create your picker.
Create an empty view with clearColor background.
Add your textfield with addSubview: to the view in step 2.
Set cameraOverlayView to the view created in step 2.
Present your picker.
In code:
//self.picker and self.textField being your UIImagePickerController and UITextField instances.
emptyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //This frame will make it fullscreen...
emptyView.backgroundColor = [UIColor clearColor];
[emptyView setAlpha:1.0]; //I think it is not necessary, but it wont hurt to add this line.
self.textField.frame = CGRectMake(100, 100, self.textField.frame.size.width, self.textField.frame.size.height); //Here you can specify the position in this case 100x 100y of your textField preserving the width and height.
[emptyView addSubview:self.textField];
self.picker.cameraOverlayView = emptyView; //Which by the way is not empty any more..
[emptyView release];
[self presentModalViewController:self.picker animated:YES];
[self.picker release];
I typed the code here myself so it could have some typo, Hope it helps!

addSubview not working

// Create and add a sub view
CGRect viewRect = CGRectMake(0, 0, 200, 200);
UIView *a_sub_view = [[UIView alloc] initWithFrame : viewRect];
[window addSubview : a_sub_view];
After adding the above 3 lines of code, xcode produces no errors or warnings. But the sub-view is not showing at all. The sample program seems to be running exactly as before. Hope that somebody knowledgable could help.
I find it useful to set the background color so I know where the view is and the boundaries.
a_sub_view.backgroundColor = [UIColor redColor];
In your example, you're create an empty view so you won't 'see' anything.
window expects a viewcontrollers view to be added.
you can then add subviews to the current view.
so in your example use:
[self.view addSubview:a_sub_view];
I am using this in order to "find" the window:
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
[window addSubview:myView];
This also worked for me, but it is a bit uglier:
[self.navigationController.tabBarController.view addSubview:myView];
To explain the second one, I had to "follow" the controllers back up to the "top" view. (My application has a tab bar with a navigation controller inside the current tab.)
If you are working with iOS 5 & above , you have to do as below:
[self.window.rootViewController.view addSubView:viewObject];
[self.view addSubView: a_sub_view];

disable elements on UIView behind modal UIView

i have a UIView that is smaller than the superview so i can represent this view as a modal view when a button is clicked.
I have managed to do the following:
* add a subview to the superview.
* centered this modal view
I am now trying to make the elements behind the UIView unclickable. And also add a grey shadow te the ourside of my modal view so that the user understands that the modal view is the view in focus.
I would like to know how to achieve this.
I do not wish to use the presentation modal transition. I know and have already implemented this in other projects.
Any help is appreciated.
The simplest thing would be to lay a fullscreen UIView with a translucent gray background behind your "modal" view. Then it will intercept all of the touches. It might look something like this:
UIView *dimBackgroundView = [[UIView alloc] initWithFrame:theSuperview.bounds];
dimBackgroundView.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:.5f];
[theSuperview addSubview:dimBackgroundView];
[theSuperview addSubview:modalView];
For future reference, you can set myView.userInteractionEnabled = NO to disable touch events on a view.
There are several ways to do it.
If you have a custom view which has custom location, you can modify it like that:
Create an instance var:
UIView* backgroundView;
And whenever you need it, put it behind your custom view:
if (backgroundView == nil)
backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width)];
backgroundView.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:.5f];
[self.view addSubview:backgroundView];
[backgroundView animateBump:customView.view];
[backgroundView addSubview:customView.view];
When you do not need it anymore
[backgroundView removeFromSuperview];