Biken Biken - 3 years ago 106
iOS Question

Automatic horizontal scroll

What should I do to automatically horizontal scroll just like app store does?

There will be bunch of images. These images with some delay come to the screen and move out and this gets repeated infinitely, like app store.

Answer Source

you can use this

Add this to your pod file

   pod 'Auk', '~> 7.0'

run pod install

  import UIKit
  struct DemoConstants {

 static let button = DemoConstantsButton()
 static let initialImage = (
    fileName: "slider1.jpg",
    description: " demo"
static let localImages = [
        fileName: "image1.jpg",
        description: "Hotel Nirvana"
        fileName: "image2.jpg",
        description: "Hotel Nirvana"
        fileName: "image3.jpg",
        description: "demo2"
        fileName: "image4.jpg",
        description: "demo3"

        fileName: "image5.jpg",
        description: "demo4"
        fileName: "image6.jpg",
        description: "demo5"

    struct DemoConstantsButton {
    let borderWidth: CGFloat = 2
    let cornerRadius: CGFloat = 20
    let borderColor = UIColor.white

In your viewcontroller

   import Auk

add delegate UIScrollViewDelegate

    class yourViewController: UIViewController ,UIScrollViewDelegate 

take a UIScrollView and make a outlet

           @IBOutlet weak var scrollView: UIScrollView!

in viewDidLoad

      scrollView.delegate = self
        for localImage in DemoConstants.localImages {

        if let image = UIImage(named: localImage.fileName) {

    let pageIndex = scrollView.auk.currentPageIndex

    scrollView.auk.settings.contentMode = UIViewContentMode.scaleAspectFill
    scrollView.auk.settings.pagingEnabled = true
    self.scrollView.auk.settings.pageControl.backgroundColor =
    scrollView.auk.startAutoScroll(delaySeconds: 3)
    scrollView.auk.scrollToPage(atIndex: 2, animated: true)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download