【问题标题】:Can I do a half m34 transformation我可以做半个m34转换吗
【发布时间】:2011-09-27 20:05:10
【问题描述】:

我想做一个完整的旋转,但图像交换到一半,我似乎无法做到这一点。完整的旋转可以在下面看到。除了漂亮的z轴东西,我怎么能做到一半呢?这是在 animateWithDuration 块中 (iOS4)

// Create perspective transformation
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
myView.layer.transform = transform; //- 3d
myView.layer.transform = CATransform3DMakeRotation(M_PI, -1, 0, 0); 

【问题讨论】:

  • 整个动画从上到下翻转,并在z轴上摆动uiimage。我想在中途做点什么,所以我想做一半的动画……然后是……然后是后半部分。我不知道是否有事件监听器会在整个翻转过程中做到这一点?
  • 对于在这里使用谷歌搜索的任何人,这可能会有所帮助stackoverflow.com/questions/37364831/…

标签: ios transform catransform3d


【解决方案1】:

你可以用两个块来做到这一点:

// Rotate the second 'backside' view to 90 degrees and hide it
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
mySecondView.layer.transform = transform;
mySecondView.layer.transform = CATransform3DMakeRotation(M_PI / 2, -1, 0, 0);
mySecondView.hidden = YES;

// Animate to 90 degrees
[UIView animateWithDuration:0.5 animations:^{
    CATransform3D transform = CATransform3DIdentity;
    transform.m34 = 1.0f / -zDistance;
    myView.layer.transform = transform;
    myView.layer.transform = CATransform3DMakeRotation(M_PI / 2, -1, 0, 0);

} completion:^{

    // Switch to the backside view
    myView.hidden = YES;
    mySecondView.hidden = NO;

    // Animate the remaining 90 degrees
    [UIView animateWithDuration:0.5 animations:^{
        CATransform3D transform = CATransform3DIdentity;
        transform.m34 = 1.0f / -zDistance;
        mySecondView.layer.transform = transform;
        mySecondView.layer.transform = CATransform3DMakeRotation(M_PI, -1, 0, 0);
    }
}

您还可以体验 myView.layer.isDoubleSided 属性,它隐藏视图的背面 - 尽管您仍然需要在动画结束时切换 hidden 标志,否则第一个视图的按钮仍然是可点击的。

希望这会有所帮助!谢谢。

【讨论】:

  • 谢谢。我真的希望这行得通,我几乎放弃了它。我回家后试试看! :)
  • @Designer023:我希望你现在已经回家了...... ;)
  • 它确实有帮助,但我仍然需要做一些摆弄
  • 酷。任何反馈?很高兴编辑我的回复。如果您想添加一些内容,也可以随意进行自己的编辑。
猜你喜欢
  • 2016-12-07
  • 2012-04-23
  • 1970-01-01
  • 1970-01-01
  • 2016-09-05
  • 1970-01-01
  • 2012-10-19
  • 2019-04-21
  • 1970-01-01
相关资源
最近更新 更多