简体   繁体   English

如何在tvOS应用程序中为collectionview的节头设置动画?

[英]how to animate section header of collectionview in tvOS app?

在此输入图像描述 Need to animate the section header title when the collection cell below the header is focused. 当焦点下方的集合单元格被聚焦时,需要为节标题标题设置动画。 Just like if you go to "movies itunes" app on apple tv and go to top movies tab, if you look at the playlists below, when you scroll through items, the header animates, up and down to not to overlap with focused cell. 就像你去苹果电视上的“电影itunes”应用程序并转到顶部电影选项卡一样,如果你看下面的播放列表,当你滚动项目时,标题会动画,上下不与重点细胞重叠。 any help is appreciated tvos screen shot link 任何帮助是赞赏tvos屏幕截图链接

I can't exactly provide the code; 我无法准确提供代码; but this is basically what you're going to want to do. 但这基本上是你想要做的。

1 - Create an intermediary class headingRouter ; 1 - 创建一个中间class headingRouter ; whose purpose will be to mediate between the scrollView header (collectionView or tableView) and the cell selection. 其目的是在scrollView标头(collectionView或tableView)和单元格选择之间进行调解。 An instance of heading router will live on your collectionView main level methods. 标题路由器的实例将存在于collectionView主级方法上。 You could use a delegate pattern to abstract out the image logic to the router and then on the collectionView; 您可以使用委托模式将图像逻辑抽象到router ,然后在collectionView上; conform to the delegate in order to update the view in question. 符合代理人以更新相关视图。

2 - Headers and footers are what is called a supplementary view ; 2 - 页眉和页脚是所谓的supplementary view ; so they can be assigned any custom subclass of uiView . 因此可以为它们分配uiView任何自定义子类。 In this headerView; 在这个headerView中; you should have a method that takes in an identifier, possibly id and changes the image displayed. 你应该有一个方法,它接受一个标识符,可能是id并更改显示的图像。 You can animate this change with a fade if you want it to look like iTunes. 如果您希望它看起来像iTunes,则可以使用淡入淡出为此更改设置动画。

3 - On your focused cell section; 3 - 在你的聚焦细胞部分; have the cells have an identifier that is assigned during the cellForRowAt method in your delegate/datasource methods. 让单元格具有在委托/数据源方法中的cellForRowAt方法期间分配的标识符。 When a specific view is focused; 当特定观点集中时; using one of the various collection/tableView methods; 使用各种collection / tableView方法之一; you want to take that id; 你想要那个id; pass it to your headingRouter , which in turn will notify your header to change it's image to the corresponding image (possible held in cache) to the image you're focusing. 将它传递给你的headingRouter ,它反过来会通知你的标题将它的图像更改为相应的图像(可能保存在缓存中)到你正在聚焦的图像。

This is more the logic of implementation; 这更多是实施的逻辑; but you haven't posted any code, so there isn't much of the way of specifics. 但是你还没有发布任何代码,所以没有太多具体细节。 You could do without the Router class but this is a cleaner solution. 你可以没有Router类,但这是一个更清洁的解决方案。

Cheers 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM