模糊 ICarousel 中的图像

Blur back Images in ICarousel

我正在我的应用程序中使用 iCarouselTypeCoverFlow 库。我想把后面的图片虚化一下。

我可以在 viewForItemAtIndex 中模糊图像。但在滚动时我无法更新。这是我的 viewForItemAtindex

代码
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
{

    image = [items objectAtIndex:index];

    button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];

    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button.titleLabel.font = [button.titleLabel.font fontWithSize:50];
    button.tag=index;

    //NSLog(@"%d %d",carousel.currentItemIndex,index);
    if (selectedindex == index) {

        [button setBackgroundImage:[items objectAtIndex:index] forState:UIControlStateNormal];

    }
    else {

        [button setBackgroundImage:[self blurredImageWithImage:[items objectAtIndex:index]] forState:UIControlStateNormal];

    }

    return button;

}

这是我的 didscroll

- (void)carouselDidScroll:(iCarousel *)carousel
{
    NSInteger current = (carousel.currentItemIndex);
   // NSLog(@"%d", current);


    NSInteger nextIndex = (carousel.currentItemIndex + 1) % carousel.numberOfItems;
   // NSLog(@"%d", nextIndex);



    NSInteger prevIndex = (carousel.currentItemIndex + carousel.numberOfItems - 1) % carousel.numberOfItems;
   // NSLog(@"%d", prevIndex);


}

如有任何建议或帮助,我们将不胜感激。

所以我终于得到了答案。绝对不希望这样。但不幸的是,答案是,

nicklockwood answer