gpt4 book ai didi

ios - iCarousel - 动态更改中心项目 iOS

转载 作者:可可西里 更新时间:2023-11-01 06:19:43 27 4
gpt4 key购买 nike

我在我的 iPad 应用程序中使用 iCarousel,我想知道是否有办法在选择时动态更改中心项目的 View 。简而言之,我想实现这样的目标 enter image description here我设法将第一个索引(项目 - 0)设置为红色,但我想不出一种方法来执行以下操作:

选择1时,我希望将0的图像更改为纯白色,并将1个更改为红色。

还有 2 个人的东西。

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

谢谢

最佳答案

如果你想选择项目然后改变颜色,那么只需简单地使用:

- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index{
//change the view of current index
}

如果你希望当前项目的颜色是红色而不需要选择,那么你需要做更多的事情:

- (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
}
}

而且你还需要使用这个方法来检查索引是否改变:

- (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel{
//you need to reload carousel for update view of current index
[self.carousel reloadData];
}

关于ios - iCarousel - 动态更改中心项目 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16055527/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com