Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

how to get current shown collectionview cell index in swift

let visibleRect = CGRect(origin: collectionView.contentOffset, size: collectionView.bounds.size)
let visiblePoint = CGPoint(x: visibleRect.midX, y: visibleRect.midY)
let visibleIndexPath = collectionView.indexPathForItem(at: visiblePoint)
Comment

how to get current shown collectionview cell index in swift

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
    for cell in yourCollectionView.visibleCells {
        let indexPath = yourCollectionView.indexPath(for: cell)
        print(indexPath)
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: set color for uibutton programmatically swift 
Swift :: how to disable uitableview scrolling in swift 
Swift :: for each swiftui 
Swift :: swift convert decimal to string 
Swift :: swift alamofire x-www-form-urlencoded 
Swift :: post API Call in swift 
Swift :: Make a VStack fill the width of the screen in SwiftUI 
Swift :: swift create a method who can return result or throw an error 
Swift :: Thread 1: breakpoint 1.1 
Swift :: swift order dictionary by key 
Swift :: convert int to string in swift 
Swift :: We use the for loop to iterate over the elements of a dictionary. 
Swift :: swift map array to dictionary 
Swift :: swift create uinavigationcontroller programmatically 
Swift :: wkwebview load delegate in swift 
Swift :: swift get current hour 
Swift :: swift change navigation bar title 
Swift :: case insensitive multiple word search swift 
Swift :: uilabel set font 
Swift :: debounce in swift 
Swift :: swift resource exceeds maximum size 
Swift :: Convert JSON to Data 
Swift :: Swift Create String Instance 
Swift :: abs swift 
Swift :: swiftui rectangle top corners radius 
Swift :: Swift break statement with nested loops 
Swift :: special symbol ios swift 
Swift :: SwifUI call the function in the cordinator 
Swift :: view rounded corners swift 
Swift :: swift float 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =