0

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
th3us3r
  • 39
  • 4
  • Are you trying to make a view that pops up from the bottom (or you can drag up from the bottom)? Doing what I think you want has nothing to do with drawing from the bottom, or the fact that iOS has the 0,0 point at the top left. – rdelmar Jul 18 '14 at 15:36
  • you need not draw a view controller. You can always present a view controller through animation. "presentViewController:animated: completion:" and also this link helps https://developer.apple.com/library/ios/featuredarticles/viewcontrollerpgforiphoneos/Introduction/Introduction.html – Srinivasan N Jul 18 '14 at 15:42
  • I am trying to pop a view from the bottom i did manage to make it to come from the top. However, when I change the height and width it concentrates in the top left corner, this is why I thought it has something to do with drawing on the screen – th3us3r Jul 18 '14 at 15:50
  • Don't change the height or width, change its position. Start it with a frame that's offscreen to the bottom, then move it up. – rdelmar Jul 18 '14 at 15:51
  • This is what I was trying to find a way to do - change the position by centralize it or something. Can you give me an example? – th3us3r Jul 18 '14 at 15:55
  • If you want to present a screen from the bottom up, you can check out this [stackoverflow question](http://stackoverflow.com/questions/3357034/how-can-i-present-a-uiview-from-the-bottom-of-the-screen-like-a-uiactionsheet). – GoGreen Jul 18 '14 at 16:24

1 Answers1

1

Heres one solution:

  1. 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)];
    
  2. 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

hackerinheels
  • 1,141
  • 1
  • 6
  • 14
  • Thanks I will try it first thing when I get home and let you know. – th3us3r Jul 18 '14 at 16:19
  • Where do I add thiis code in the main VC is it in particular function in the main VC or i must add it to AppDelegate in application didFinishLaunchingWithOptions "self.rolloutView = [[UIView alloc]initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height, [[UIScreen mainScreen] bounds].size.width, heightYouWant)];" – th3us3r Jul 21 '14 at 16:01