Reputation: 8957
I have an iphone application in which in a button click i am showing a view like an alertview.at that time i want my remaining views (background) to be a shadow one,like as we see the background when showing the alertview.Can anybody help me to achieve this?
Upvotes: 0
Views: 1123
Reputation: 271
Best way is to create a new image (black translucent background patch) and add in the background of the superview and set the background color of superview as clearcolor.
Upvotes: 0
Reputation: 38249
When a button click for showing a view:
-(void)yourButtonAction
{
[self.view setAlpha:0.3];
}
Now when removing view like an alertview.
[self.view setAlpha:1.0];
Upvotes: 0
Reputation: 523
You can simply add a UIView as a subview of your controller view. Set black as the backgroundColor of it with an alphaValue between 0 and 1. Remember to set the frame equals to the viewcontroller view
In your alertview callback, just remove the view.
Upvotes: 0
Reputation: 13459
This is rather simple, make your new view a sub view of a view that covers the full screen with alpha set to 0.7 or something and the color of your choosing, then present this view and everything behind should be darkened.
Upvotes: 1
Reputation: 109
You can just alloc a view with the main view's frame, and set the background color to gray, when you click the button, add this view and then add the specified view or you can add the specifed view in this gray view....
Upvotes: 0