Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do this via the <code>iCarousel</code>'s <code>iCarouselTypeCustom</code> type in the delegate method </p> <pre><code>- (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform </code></pre> <p>Just set the type of the carousel (e.g. in <code>viewDidLoad</code> of the carousel's view controller):</p> <pre><code>self.carousel.type = iCarouselTypeCustom; </code></pre> <p>And calculate the transform as you like. I've laid the objects on a hyperbola, and shrink them in addition a bit as they move away from the center. That quite resembles your image, I think:</p> <pre><code>- (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform { const CGFloat offsetFactor = [self carousel:carousel valueForOption:iCarouselOptionSpacing withDefault:1.0f]*carousel.itemWidth; //The larger these values, as the items move away from the center ... //... the faster they move to the back const CGFloat zFactor = 150.0f; //... the faster they move to the bottom of the screen const CGFloat normalFactor = 50.0f; //... the faster they shrink const CGFloat shrinkFactor = 3.0f; //hyperbola CGFloat f = sqrtf(offset*offset+1)-1; transform = CATransform3DTranslate(transform, offset*offsetFactor, f*normalFactor, f*(-zFactor)); transform = CATransform3DScale(transform, 1/(f/shrinkFactor+1.0f), 1/(f/shrinkFactor+1.0f), 1.0); return transform; } </code></pre> <p>and the result: <img src="https://i.stack.imgur.com/DoRPk.png" alt="result"></p> <p>you can adjust the float constants to your liking.</p> <p>For moving items around a circle while scaling them just use goniometric functions for translation, then rotate and scale:</p> <pre><code>- (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value { if (option == iCarouselOptionSpacing) { return value * 2.0f; } if(option == iCarouselOptionVisibleItems) { return 11; } if(option == iCarouselOptionWrap) return YES; return value; } - (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform { const CGFloat radius = [self carousel:carousel valueForOption:iCarouselOptionRadius withDefault:200.0]; const CGFloat offsetFactor = [self carousel:carousel valueForOption:iCarouselOptionSpacing withDefault:1.0f]*carousel.itemWidth; const CGFloat angle = offset*offsetFactor/radius; //... the faster they shrink const CGFloat shrinkFactor = 2.0f; //hyperbola (now only for shrinking purposes) CGFloat f = sqrtf(offset*offset+1)-1; transform = CATransform3DTranslate(transform, radius*sinf(angle), radius*(1-cosf(angle)), 0.0); transform = CATransform3DRotate(transform, angle, 0, 0, 1); transform = CATransform3DScale(transform, 1/(f*shrinkFactor+1.0f), 1/(f*shrinkFactor+1.0f), 1.0); return transform; } </code></pre> <p>and again, the result: <img src="https://i.stack.imgur.com/QF65T.png" alt="result2"></p> <p>you can adjust the spacing and the radius in the <code>carousel:valueForOption:withDefault:</code> method.</p> <p>Enjoy! :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload