Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift paged scrollview get current page

// Swift 5

self.scrollView.delegate = self

// Changed the page property when the user scrolls over 50% of the current page.
// Page starts with 0
func scrollViewDidScroll(_ scrollView: UIScrollView) {
  let scrollViewWidth = scrollView.bounds.width
  self.page = Int(round(scrollView.contentOffset.x / scrollViewWidth))
}

var page: Int {
    didSet {
        guard oldValue != self.page else {
          return 
        }
      	// Handle page update
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: initialize array with zero in swift 
Swift :: swiftui radio button 
Swift :: Nested if...else Statement 
Swift :: response.result.value alamofire 5 
Swift :: swift string 
Swift :: swift extension Array with type 
Swift :: how to include a library in swift 
Swift :: Swift if..else if 
Swift :: get last element of array swift 
Swift :: swift create custom button with icon programmatically 
Swift :: swift reduce function 
Swift :: Swift Half-Open Range 
Swift :: Swift Create String Instance 
Swift :: Type Constraints Swift 
Swift :: Swift Access Struct Properties Swift 
Swift :: Swift Computed Property In Extension 
Swift :: async await apis for ios 13 
Swift :: Button on right side/view of UITextField 
Swift :: swift memberwise initializer 
Swift :: chevrondownf6a06a60-2122-49d0-86a0-03ba8c532aec 
Swift :: Define Swift Structure 
Swift :: Swift Find Number of Array Elements 
Swift :: Swift break statement with for loop 
Swift :: Struct Instances Swift 
Swift :: swiftui lowercase 
Ruby :: ERROR: While executing gem ... (Gem::FilePermissionError) 
Ruby :: copy to clipboard in ruby in windows 
Ruby :: rails routes grep 
Ruby :: ruby map with index 
Ruby :: ruby string to int 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =