• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
-replaceSubview transition animation that is applied to both old and new subviews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-replaceSubview transition animation that is applied to both old and new subviews


  • Subject: -replaceSubview transition animation that is applied to both old and new subviews
  • From: Nick <email@hidden>
  • Date: Thu, 29 Oct 2015 08:55:18 +0200

Hi
I am trying to do a nice sliding effect (that looks to the user as Calendar
scrolling), but for pages. So basically I have several pages that I want to
present to the user one by one, that he can flip with a trackpad gesture.

I am using a kCATransitionFromLeft animation, when the pages are being
flipped backwards:

-(IBAction)prevPage:(id)sender {
    if(self.currentPageIndex <= 0)
        return; //no previous subview

    [self.pageDisplayView
removeConstraints:self.pageDisplayView.constraints];

    CATransition *trans = [CATransition animation];
    trans.type = kCATransitionMoveIn;
    trans.subtype = kCATransitionFromLeft;
    self.pageDisplayView.animations = @{@"subviews": trans};

    [[self.pageDisplayView animator]
replaceSubview:self.pages[self.currentPageIndex]
with:self.pages[self.currentPageIndex-1]];
    self.currentPageIndex--;

    NSDictionary *subView = @{@"page": self.pages[self.currentPageIndex]};
    NSArray *hConstraints = [NSArray array];
    hConstraints = [hConstraints
arrayByAddingObjectsFromArray:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|[page]|" options:0 metrics:nil
views:subView]];
    NSArray *vConstraints = [NSArray array];
    vConstraints = [hConstraints
arrayByAddingObjectsFromArray:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|[page]|" options:0 metrics:nil
views:subView]];
    [self.pagedisplayView addConstraints:hConstraints];
    [self.pageDisplayView addConstraints:vConstraints];
}

But the problem is that the previous (old) subview, that is being replaced
by the new one, does not animate - only the new one does. So it doesn't
look like scrolling, more like the new page goes over the old page.
I would like to have the old subview move from right to left as it
disappears (as in slide out) as well.
How could I achieve this?

And just as a subquestion, how is continuous swipe gesture tracking usually
implemented?  Basically I was hoping to have the user to be able to swipe
the pages left (go to the next page) and right (go to the prev page), but
in such a way that while his fingers are still on the trackpad, the page
doesn't move away completely but stays "in a transition". Something like
pages in Safari, when you go back and forward with the swipe gesture but do
not take the fingers off the trackpad. I was wondering how did Apple do
this?

Thank you for reading this far and possible suggestions!
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: -replaceSubview transition animation that is applied to both old and new subviews
      • From: Nick <email@hidden>
  • Prev by Date: Re: Smooth adjustScroll of NSScrollView
  • Next by Date: AppleScript-ObjC Bridge Question
  • Previous by thread: Re: mysterious behavior of system font metrics
  • Next by thread: Re: -replaceSubview transition animation that is applied to both old and new subviews
  • Index(es):
    • Date
    • Thread