ios - Custom UIView resizing while recognizing pan gesture -


i'm trying achieve following effect. have view can in 2 different states - collapsed , expanded). see screenshots have in mind:

collapsed expanded

transition between these states should triggered panning gesture - user panned down view gets expanded, user panned - view gets collapsed.

i can achieve implementing custom gesture recognizer in init section of view subclass:

uipangesturerecognizer* recognizer = [[uipangesturerecognizer alloc] initwithtarget: self action: @selector(panned:)]; recognizer.delegate = self; [self addgesturerecognizer: recognizer]; 

and detecting proper vertical pan gesture:

- (void)panned:(uipangesturerecognizer*)gesturerecognizer {     static cgpoint lastpoint;     if (gesturerecognizer.state == uigesturerecognizerstatebegan) {         lastpoint = [gesturerecognizer locationinview: self];         return;     }      if (gesturerecognizer.state == uigesturerecognizerstateended) {         if (p.y > lastpoint.y && self.expanded == no) {             [self toggle];         }         else if (p.y < lastpoint.y && self.expanded == yes)         {             [self toggle];         }     } } 

based on self.expanded property layout subviews , change frame accordingly. works more or less ok. issue have - i'd show transition between 2 states user panning finger - view should start expanding gradually , forth (if user pans , forth) , come expanded state when gesture complete.

what's easiest way this?

what devise animation between collapsed state , expanded state. (this might involve changing 1 view on time, or fading / moving between 2 different views, 1 in collapsed state , other in expanded state.) drive animation in accordance gesture, explain here:

https://stackoverflow.com/a/22677298/341994

basically, attach animation layer, speed set 0 nothing happens. track gesture , keep changing timeoffset of layer change "frame" of animation match.

(one can't observing, in connection, done custom transition animation - i.e., transition between views of 2 view controllers add own interactive animation. so, if ios 7 only, might simplest use custom transition animation. is how weekly-monthly transition in calendar app achieved, appositely mention in comment - it's push/pop transition custom interaction animation.)


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -