iPhone - 旋转木马 [英] iPhone - Carousel

查看:221
本文介绍了iPhone - 旋转木马的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用开源, iCarousel 来启用轮播控件。我使用的轮播类型是 iCarouselTypeRotary ,图像按此类型线性排列。但是,我需要像附加图像中的旋转木马一样带来图像。我应该怎么做才能使我的旋转木马在下图中的样式中略微倾斜到顶视图?请帮助。在此先感谢。

I use open source, iCarousel in my application to bring the carousel control. The carousel type which I use is iCarouselTypeRotary and the images are arranged linearly in this type. But, I need the images to bring like the carousel in the attached images. What should I do to make my carousel little tilted to the top view as the style in the below images? Kindly help. Thanks in advance.


推荐答案

您可以手动实现3D倾斜:

You can implement 3D tilt manually:

iCarousel.m 574

return CATransform3DTranslate(transform, radius * sin(angle), 0.0f, radius * cos(angle) - radius);

更改为:

float tilt = MAX_TILT_VALUE * cos(angle); // greater angle means greater vertical offset
return CATransform3DTranslate(transform, radius * sin(angle), tilt, radius * cos(angle) - radius);

为了使代码清晰可重复使用,请实施倾斜偏移作为选项(类似于 iCarouselOptionArc )。

To make the code clear and reusable, implement tilt offset as option (similar to iCarouselOptionArc).

PS:如果你想要透视缩放,你需要添加依赖于的缩放变换cos(角度)类似于倾斜

PS: If you want perspective scaling, you will need to add scale transform that depends on cos(angle) similarly to tilt.

这篇关于iPhone - 旋转木马的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆