I want to pass option set for scroll position as parameter argument, but facing some issue.
Please can anyone write how to do it?
func selectCurrentWallpaperCell() { //want to pass parameter here
let currentWallpaperID = self.wallpaperManager.currentWallpaperID
if let index = self.wallpapers.index(where: { $0.id == currentWallpaperID }) {
let indexPath = IndexPath(item: index, section: 0)
self.collectionView.selectItem(at: indexPath, animated: true, scrollPosition: UICollectionViewScrollPosition()) // how to use in scrollposition?
}
}
let options: UICollectionViewScrollPosition = [.top, .centeredVertically]
self.collectionView.selectItem(at: indexPath, animated: true, scrollPosition: options)
Reference: OptionSet