Search code examples
iosobjective-cscrollicarousel

Blur back Images in ICarousel


I am using iCarouselTypeCoverFlow library in my app. I want to blur the back images.

I am able to blur images in viewForItemAtIndex. but while scrolling i am not able to update. here is my code for 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;

}

and here is my 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);


}

Any suggestion or help would be appreciated.


Solution

  • So finally i got my answer. definitely not hoping for this . but unfortunately answer is ,

    nicklockwood answer