美文网首页iOS绘图与动画
模拟tvOS中的3D浮动效果动画

模拟tvOS中的3D浮动效果动画

作者: JoyceZhao | 来源:发表于2016-09-01 14:25 被阅读304次
  • 涉及到的技术点
    • CATransform3DRotate
    • 转换坐标系
  • 整体视图的层级结构
    • tvOSCardView
    • cardImageView
    • cardParallaxView
  • 转换坐标系的代码
CGFloat xFactor = MIN(1, MAX(-1, (touchPoint.x - (self.bounds.size.width / 2)) / (self.bounds.size.width / 2)));
CGFloat yFactor = MIN(1, MAX(-1, (touchPoint.y - (self.bounds.size.height / 2)) / (self.bounds.size.height / 2)));
        
 cardImageView.layer.transform = [self transformWithM34:1.0 / -500 xf:xFactor yf:yFactor];
 cardParallaxView.layer.transform = [self transformWithM34:1.0 / -250 xf:xFactor yf:yFactor];
        
  CGFloat zFactor = 180 * atan(yFactor / xFactor) / M_PI + 90;
  • tvOSCardAnimation动画的运行结果
运行结果图8.gif
附上项目所在GitHub地址:https://github.com/zhaoqianJoyce/tvOSCardAnimation

相关文章

网友评论

本文标题:模拟tvOS中的3D浮动效果动画

本文链接:https://www.haomeiwen.com/subject/kjncettx.html