Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Push a UIImageView with another UIImageView, possible?
- - (void) didMove:(UIPanGestureRecognizer*)recognizer {
- UIView* view = [recognizer view];
- // Remember our UIImageViews are class members called, a & b
- //
- UIView* otherView = view == a ? b : a;
- if (recognizer.state == UIGestureRecognizerStateBegin
- || recognizer.state == UIGestureRecognizerStateChanged) {
- // Moving left will have a negative x, moving right positive
- //
- CGPoint translation = [recognizer translationInView:view.superview];
- view.center = CGPointMake(view.center.x + translation.x, view.center.y);
- // Reset so we always track the translation from the current view position
- //
- [recognizer setTranslation:CGPointZero inView:view.superview];
- if (CGRectIntersectsRect(view.frame, otherView.frame)) {
- // Translate by the same number of points to keep views in sync
- //
- otherView.center = CGPointMake(otherView.center.x + translation.x, otherView.center.y);
- }
- }
- }
Add Comment
Please, Sign In to add comment