Viv*_*k T 3 ipad ios icarousel
我在我的iPad应用程序中使用iCarousel,我想知道是否有办法在选择时动态更改中心项目的视图.总之,我想实现这样的目标
我设法将第一个索引(项目 - 0)设置为红色,但我无法找到一种方法来执行以下操作:
当选择1时,我希望将0的图像更改为纯白色,将1的图像更改为红色.
也是2件事.
任何帮助或建议将不胜感激.
谢谢
bri*_*ple 13
如果您想选择项目然后更改颜色,那么只需使用:
- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index{
//change the view of current index
}
Run Code Online (Sandbox Code Playgroud)
如果你想要当前的项目颜色为红色而没有选择,那么你需要做更多的事情:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
//Here you need to check current index
if (index == self.carousel.currentItemIndex) {
//change the view
}
}
Run Code Online (Sandbox Code Playgroud)
而且您还需要使用此方法来检查索引是否已更改:
- (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel{
//you need to reload carousel for update view of current index
[self.carousel reloadData];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3589 次 |
| 最近记录: |