How to set this Layout in iPhone need Some help - iphone

I have Implement Some paint like application. For that the Layout is like as below:
Here, there is One View and two buttons. In My application i am selecting the colour from Button2 and then doing drawing on View.
But the Problem is while i am selecting the Colour and if i do the Paint on the View, all works file but if that paint come over the Button1, it also paint on that button1. I want set as like that the selection colour Should not be paint on the Button1 and only paint on the View.
So for that What Should i have to do ?
I want to set the Button1 in front of the View and do not allow to paint on it.
please Guide me proper regarding this mater.
Thanks.

You have to make sure your buttons are not subviews of the view you are drawing in.
The simplest way to do this is to organize your buttons and your view in interface builder so that you have a UIView within your window as well as your buttons which must be on a higher layer than your UIView but cannot be inside your UIView. I would post pictures if the site would let me. You will then need to make a UIView IBOutlet to attatch to the UIView in Interface Builder and to draw to in your code.
To do this programmatically, after you have created your buttons, create a UIView and add it as a subview to your viewController's view by using (if myView is your UIView)
[self.view addSubview:myView]
and then use
[self.view send SubviewToBack:myView]
to make sure it is behind your other subviews (your buttons). Draw to myView and it should appear behind the buttons.

Related

How to put my 2 existing buttons to the foreground, they are now behind an imageview

The question is in the title.
There must be a simpel way to do this I guess?
There is an imageview on the screen, there doesn't have to be any interaction with it.
On the imageview I want 2 small buttons left and right but the buttons were created (and the code is written) before the imageview. How do I set this imageview to the background? :)
[self.view sendSubviewToBack:yourImageView];
You can add buttons as subview of imageview.
you can write below code for that:
[imageView addSubview:button1];
[imageView addSubview:button2];
So buttons will be appear in foreground.
When looking at your xib or stoyboard (where you can see the layout), you can use the View Controller scene which is a list of all of the objects, views etc on your Apps layout.
You can click and drag the UI image view so its above the buttons in the list. I'm guessing it's just defaulted to being on top of the buttons.
In your storyboard, choose your viewController by clicking on it. On left side you can see hierarchy like left side view in this image. Check if your imageView is below, in hierarchy, to your 2 buttons. If it is, then drag the imageView and move it above both the buttons.
Concept : The view that is below in hierarchy is visible on top of all the views above it.

how to make a custom viewController with transparent black background?

I'm trying to make a viewController appears like the small one in the middle of the picture :
I tried with the UiAlertView, but it semms not offering this feature.
I found some apps adding buttons and labels, photo in similar viewControllers.
Any idea ?
It's not a view controller - it looks like a view that is added as a subview.
The middle View in the image is not a viewcontroller. It is just a custom UIView made up using images and buttons. You can set the transparency of a UIView using property alpha.
Example
yourview.alpha = 0.5;

Create UIButton offscreen with Interface Builder

I want to create a big UIScrollView, its contentView should contain more than 30 UIButton. Positions of these UIButton are not rectiligne and cannot be create 'programmaticaly' so I've placed all these UIButton on a UIView manually. I zoom/dezoom and scroll all over my UIScrollView fine BUT here is my problem : UIButton created offscreen is not accessible, I mean I can't click them (only UIButton created in the CGRect(0.f, 0.f, 320.f, 480.f) can be click.
Any suggestion ?
Create a view, put a scrollView inside that view, and place your buttons on the scrollView. While adding buttons and moving them around, be certain that they're always inside the scrollView by looking at the object hierarchy in interface builder.
You can slide the scrollView around as you place things, no need to zoom. As long as your buttons are children of your scrollView it should work fine.

Shadow inside UIView

I am working on iPhone application development and have come across shadows of UIView.
I know how to show shadows to a UIView but what I am actually interested in is to drop shadow inside the UIView.
Like when I set shadow properties of a UIView the shadow is dropped behind the view. I want it to come over the view so that the view looks as if it is pressed inside.
Example of such view is UITextField with roundedRect styling.
Thanks,
It depends a lot on the final effect you want to achieve.
The easies way would be a custom image with a prebacked shadow as background. This will give the illusion of a recession in the surface of the view. You can then add subviews to it as usual.
Alternatively, you can override the drawRect: method and draw the view as you like there, "inverted drop shadow" included.

iPhone UIScrollview: Button does not respond when located below 480 pixels on Scroll View's child UIView

I have built a view for an iPhone app in Interface Builder. It is a UIScrollview with a UIView and a UIButton on the UIView. The only code I have is setting the scroll view's contentSize to 320x550 in the viewDidLoad method of the xib's File Owner class. When the button is within the normal view area (320x480) the button responds as normal, but if is placed outside of those boundaries in Interface Builder the button will not respond when I scroll to it and click the button.
What am I missing? I figure it might be something I need to set on the UIView. But I am not sure what that is.
Your UIButton won't response even it's visible because it's not in the boundary of parent view. You can see object outside the boundary of its parent view because it's a default behavior of UIView to draw all subview (clipsToBounds = NO)
To see the truth, try this code.
UIView *yourUIView = ...
yourUIView.clipsToBounds = YES;
yourUIView.backgroundColor = [UIColor cyanColor];
You will no longer see your UIButton.
To fix this, enlarge your UIView.
I had the same problem as the person who posted the question. Thanks to the first answer, I had a hint as to what to do. I increased the height of the view by adjusting the frame. This, apparently must be done in code. Once this was done, however, the toolbar at the bottom was no longer visible. So before I adjust the height of the view, I grab the position of the tool bar. Then after adjusting the height of the view, I reset the position of the tool bar. Now all is good.