Scale items with iCarousel

后端 未结 3 1504
我在风中等你
我在风中等你 2020-12-13 11:17

I was trying to use iCarousel for one my solutions, I need to achieve something like the image below \"enter

3条回答
  •  星月不相逢
    2020-12-13 11:46

    I do not have enough reputation to comment so i have to ask a further question as a reply :(

    @burax is it possible to layout items on linear line instead of a hyperbola but keep the resizing?

    Regards, and sorry for asking like this

    Edit : with random tries i achieved with this :

    - (CATransform3D)carousel:(iCarousel *)carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform
    {
    const CGFloat radius = [self carousel:carousel valueForOption:iCarouselOptionRadius withDefault:5050.0];
    const CGFloat offsetFactor = [self carousel:carousel valueForOption:iCarouselOptionSpacing withDefault:0.8f]*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;
    }
    

    there is probably a better way but i am new to transformations :)

提交回复
热议问题