Reputation: 39
I am trying to develop an app in Xcode. I am new in Objective C programming but so far I did OK. Today I got my first problem. I am trying to draw a transparent VC (View Controller) from the bottom up but I do not know how I can accomplish this. I know that drawing in iPhone begins from 0,0 coordinates from top left corner going right and down. Is there a way to kind of cheat and draw the VC from the bottom to top 70% covering the screen, just like the tools menu when swipe up on iPhone screen in iOS 7.x.x
Thanks in advance.
Upvotes: 0
Views: 332
Reputation: 1141
Heres one solution:
Create the view as a subview of the main view in this controller.
self.rolloutView = [[UIView alloc]initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height, [[UIScreen mainScreen] bounds].size.width, heightYouWant)];
When the user takes the action, call this function
-(void)toggleView:(id)sender
{
__block CGRect frame = self.rolloutView.frame;
// Check if the frame's origin.y is at the bottom of the screen
if(self.rolloutView.frame.origin.y == [[UIScreen mainScreen] bounds].size.height){
// if it is, reduce it by the height of the view you eventually want
frame.origin.y = [[UIScreen mainScreen] bounds].size.height-heightYouWant ;
}
else{
// else push it down again
frame.size.height = [[UIScreen mainScreen] bounds].size.height;
}
[UIView animateWithDuration:.3
animations:^{
self.rolloutView.frame = frame;
}
completion:nil];
}
I have not compiled the code but it should give you the idea on what i am suggesting
Upvotes: 1