do you want to achieve this?
Here are two different viewControllers
one above other one. vc2
is a childViewController
of vc1
with a transparent
background. In your case you can put a UILabel
top of the stack with backgroundColor
black
and alpha = 0.5
.
All events of vc2
will fire on vc2.m
. Use this code on image click:
- (IBAction)imageClick
{
vc2 *viewController = [[vc2 alloc]init];
[self addChildViewController:viewController];
viewController.view.frame = self.view.frame;
[self.view addSubview:viewController.view];
viewController.view.alpha = 0;
[viewController didMoveToParentViewController:self];
[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^
{
viewController.view.alpha = 1;
}
completion:nil];
}
And in vc2.m
put this on viewDidLoad
to make this viewController
transparent.
self.view.backgroundColor = [UIColor clearColor];
self.view.opaque = YES;
Making transparent view a viewController
will make your code clean as all code of vc2
will be in a separate class.
EDIT
So do one thing, First add a UIView
to your xib
which will be a rounded border and frame will be that you want as per your screenshot.
For rounded border, you can use this category
. backgroundColor
of this UIView
will be clearColor
:
- (void)setRoundedBorder:(float) radius borderWidth:(float)borderWidth color:(UIColor*)color
{
CALayer * l = [self layer];
[l setMasksToBounds:YES];
[l setCornerRadius:radius];
// You can even add a border
[l setBorderWidth:borderWidth];
[l setBorderColor:[color CGColor]];
}
Now put a UILabel/UIView/UIImage
whose frame is equal to UIView
above and alpha is 0.5 with black background color. You can do this directly from xib
. No need to set frame through code.
Then start putting your other controls inside UIView