具有帮助CATransform3D或CGAffineTransform的特定转换矩形

时间:2013-06-11 22:48:22

标签: iphone ios cgaffinetransform catransform3d

有没有办法像图片一样改变?

http://i.imgur.com/vOMqZ1e.png

修改

现在,为了转换,我使用下一个代码:

    - (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform {
   transform.m34 = - 0.0004;
   CGFloat clampedOffset = fmaxf(-1.0f, fminf(1.0f, offset));
   CGFloat x = (clampedOffset * 0.5f * _tilt + offset * _spacing) * kWidthView;
   CGFloat z = fabsf(clampedOffset) * - kWidthView * 0.5f;
   transform = CATransform3DTranslate(transform, x, 0.0f, z);
   return CATransform3DRotate(transform, -clampedOffset * M_PI_2 * _tilt, 0.0f, 1.0f, 0.0f);
}

1 个答案:

答案 0 :(得分:0)

将透视变换与围绕y(垂直)轴的旋转相结合 并将其应用于视图的图层应该会产生这种效果,例如:

CATransform3D transform = CATransform3DIdentity;
transform.m34 = -1.0/200.0;
transform = CATransform3DRotate(transform, 45.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
layer.transform = transform;