(Newbie) How do I get this effect in my app

Discussion in 'iOS Programming' started by MHayez, Jun 15, 2016.

  1. MHayez macrumors newbie

    MHayez

    Joined:
    Jun 15, 2016
    #1
    As you can see in the pictures I attached the app has 2 frames that can be dragged up and down and have curved edges at the top. How could I go about doing something similar to this in my app. What would i need to learn how to code to get this effect?

    If you need more detail into what i'm talking about, ask me any questions. Any help or direction would greatly help me
     

    Attached Files:

  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    The rounded corners are made by setting view.layer.cornerRadius = 10 (or a similar value). The images show only the top corners as rounded. I'll leave that up to you to figure out how to do that.

    Code:
    view.layer.cornerRadius = 10
    view.layer.masksToBounds = true
    
    Adjusting the size or position of a view in response to a finger drag is a matter of using a gesture recognizer to track the finger and then adjusting the view's frame in the gesture recognizer's callback method. I think you need a UIPanGestureRecognizer. You could set view.frame but these days you're probably using constraints. You'll need an IBOutlet to the top constraints for your views and you'll need to set the constant property to force the view to update its frame. I think you're expecting the back view to never be completely hidden by the front view so you'll need to adjust the height of both views when the front view gets to a certain height.

    Thanks for asking.
     
  3. bozokelly macrumors newbie

    Joined:
    Jun 14, 2016
    Location:
    Perth
    #3
    I've just started coding and learning about app development, man there is SO MUCH to learn. Loving it though. :)
     
  4. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #4
    That's interesting. I always set 'clipsToBounds', not 'masksToBounds'. I wonder what the difference is.
     
  5. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    Code:
    UIView.clipsToBounds()
    UILayer.masksToBounds()
    
    Otherwise they're the same.
     
  6. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #6
    Well yes, clipsToBounds is a property of the view not the layer. But asides from that they're the same thing? I've never seen a difference myself.
     

Share This Page