I have set images in iCarousel. When I scroll the carousel, it shows images in front and back. I do not want to display images in back. Please help. Thank you.
You should implement the delegate:
- (CGFloat)carousel:(iCarousel *)_carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value{
switch (option)
{
case iCarouselOptionVisibleItems:
{
return numberOfItemsIntheFront;
}
}
}
You'll need to change to a custom carousel type, and copy the implementation of iCarouselTypeRotary in your delegate. Then implement -carousel:itemAlphaForOffset:
so that items around the back have an alpha of zero.
In the latest version of iCarousel, the easiest way to do this is to set view.layer.doubleSided = NO on your carousel item views, or to use the iCarouselOptionShowBackfaces property, like this:
- (CGFloat)carousel:(iCarousel *)_carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
switch (option)
{
case iCarouselOptionShowBackfaces:
{
return NO;
}
default:
{
return value;
}
}
}
Code below will nicely fade away items that are going to the back. Enjoy.
func carousel(carousel: iCarousel, valueForOption option: iCarouselOption, withDefault value: CGFloat) -> CGFloat
{
if (option == .Spacing)
{
return value * 1.1
}
else if (option == .FadeMin)
{
return 0;
}
else if (option == .FadeMax)
{
return 0;
}
else if (option == .FadeRange)
{
return 3;
}
return value
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With