iOS開發 仿淘寶,京東商品詳情3D動畫


- (void)show {

  [[UIApplication sharedApplication].windows[0] addSubview:self.projectView];

  CGRect frame = self.projectView.frame;

  frame.origin.y = fView_Height(self.view) - 480*DY_Proportion;

  @weakify(self)

  [UIView animateWithDuration:0.25 animations:^{

    @strongify(self)

    [self.groundView.layer setTransform:[self firstTransform]];//紅色view調用了上面的旋轉效果

  } completion:^(BOOL finished) {

    @strongify(self)

    [UIView animateWithDuration:0.25 animations:^{

      @strongify(self)

      //旋轉完成以后頁面縮小 同事改變黃色頁面的frame的y值

      [self.groundView.layer setTransform:[self secondTransform]];

      //顯示maskView

      [self.maskView setAlpha:0.5f];

      //popView上升

      self.projectView.frame = frame;

    } ];

  }];

}

 

- (void)close { 

  CGRect frame = self.projectView.frame;

  frame.origin.y = fView_Height(self.view) + 30*DY_Proportion;

  @weakify(self)

  [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{

    @strongify(self)

    //maskView隱藏

    [self.maskView setAlpha:0.f];

    //popView下降

    self.projectView.frame = frame;

    //同時進行 感覺更絲滑

    [self.groundView.layer setTransform:[self firstTransform]];

    

  } completion:^(BOOL finished) {

    @strongify(self)

    [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{

      @strongify(self)

      //變為初始值

      [self.groundView.layer setTransform:CATransform3DIdentity];

      

    } completion:^(BOOL finished) {

      @strongify(self)

      //移除

      [self.projectView removeFromSuperview];

    }];

    

  }];

}

 

- (CATransform3D)firstTransform{

  CATransform3D t1 = CATransform3DIdentity;

  t1.m34 = 1.0/-900;

  //帶點縮小的效果

  t1 = CATransform3DScale(t1, 0.98, 0.98, 1);

  //繞x軸旋轉

  t1 = CATransform3DRotate(t1, 15.0 * M_PI/180.0, 1, 0, 0);

  return t1;

  

}

 

- (CATransform3D)secondTransform{

  

  CATransform3D t2 = CATransform3DIdentity;

  t2.m34 = [self firstTransform].m34;

  //向下移

  t2 = CATransform3DTranslate(t2, 0, 0, 0);

  //第二次縮小

  t2 = CATransform3DScale(t2, 0.90, 0.90, 1);

  return t2;

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM