iCarousel空间旋转木马项目并隐藏背景中的项目

时间:2015-10-30 20:52:38

标签: ios icarousel

我正在使用iCarouselTypeRotary。我想要对项目进行分隔,以使它们之间存在x值的差距,同时隐藏不是前3个视图的视图。

我试过了

- (CGFloat)carousel:(iCarousel *)_carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
//customize carousel display
    switch (option)
    {
        case iCarouselOptionShowBackfaces:
            return NO;
        case iCarouselOptionSpacing:
        {
            //add a bit of spacing between the item views
            return value * 1.2f;
        }
         default:
        {
        return value;
        }
    }
}

但这只是视图的空格,它不会隐藏背景项。

非常感谢提前

1 个答案:

答案 0 :(得分:2)

You have add one more case in your switch case for only visible 3 views at a time and remaining will be invisible

- (CGFloat)carousel:(iCarousel *)_carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
//customize carousel display
    switch (option)
    {
        case iCarouselOptionShowBackfaces:
        {
            return NO;
        }
        case iCarouselOptionSpacing:
        {
            //add a bit of spacing between the item views
            return value * 1.2f;
        }
        case iCarouselOptionVisibleItems:
        {
           return 3;
        }
        default:
        {
            return value;
        }
    }
}