I don’t know what you mean by “automatic scrolling”, but to change the cell of the collection view you can use the didUpdateFocusInContext file in your custom cell class.
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { coordinator.addCoordinatedAnimations({ [unowned self] in if self.focused { self.titleTopConstraint.constant = 27 self.titleLabel.textColor = UIColor.whiteColor() } else { self.titleTopConstraint.constant = 5 self.titleLabel.textColor = UIColor(red: 100 / 255, green: 100 / 255, blue: 100 / 255, alpha: 1) } self.layoutIfNeeded() }, completion: nil) }
Or, if you do not have a custom cell, use the didUpdateFocusInContext file from the UICollectionViewDelegate.
func collectionView(collectionView: UICollectionView, didUpdateFocusInContext context: UICollectionViewFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { coordinator.addCoordinatedAnimations({ () -> Void in if let indexPath = context.nextFocusedIndexPath, let cell = collectionView.cellForItemAtIndexPath(indexPath) {
source share