simple Touch rectangle --> animate

Discussion in 'iOS Programming' started by macRumorsUserX, Mar 10, 2015.

  1. macRumorsUserX macrumors newbie

    Joined:
    Feb 2, 2015
    #1
    I must be honest. After almost a month of learning swift, I am still baffled everyday when I try to do the most simple things. Many of the written tutorials don't address the more simple things. And Apple's developer Library tells me all of the functions and objects but it gives so little I don't know how to implement them. If anyone knows any good resources for swift implementations let me know.

    So, what i'm trying to do today is animate a rectangle. I have a simple UI.animateWithDuration that doubles the size of the rectangle over 1 second.

    I want this animation to run whenever the user touches inside the rectangle. Not "tap" or long press. but ANY time they touch. (for example they are touching the ipad screen and moving their finger along and it enters the rectangles bounds. (is it bounds or frame?).

    so what is the simple code for triggering this animation when the user touches their? i know it has something to do with touchesBegan(NSSEt) .. whatever... and CGRect contains point.

    I get the basic concepts but always fail to implement it because of the many many various syntactical errors that await me on every line.

    hope to get some good answers and good ideas on how to learn swift quicker
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    You should be sure to check out Ubuntu's response to your similar query in your other thread.

    Perhaps you should step away from the real coding and spend some time learning how to write syntactically correct code. Then as you become more comfortable and successful with how it all fits together, you can also become more productive. Just a suggestion.
     
  3. macRumorsUserX thread starter macrumors newbie

    Joined:
    Feb 2, 2015
    #3
    thanks for the advice but I already tried LongPressGestureReocognizer and it isn't exactly one im' looking for. GCRectContainsPoint turned out to be closer to what I need.

    and as far as "taking a break" to learn code. I read coding books and I'm learning swift as I go along. I've only just started so it isn't helpful when someone says use "This object" with no implementation example.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Did you look at the rest of UIGestureRecognizer, like UITapGestureRecognizer?

    Well, Swift is pretty new so you're going to find much less examples out there. I find it helps to add "example" as a keyword when searching to find sample implementations. For example, I found this Ray Wenderlich tutorial by Googling for "swift programming uigesturerecognizer example".
     

Share This Page