Skip to content

Instantly share code, notes, and snippets.

let companyArray = ["Google", "Amazon", "Apple", "AirBnb", "Instagram", "Facebook", "Stripe", "Microsoft", "Twitter", "Snap"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
view.addSubview(scrollView)
imageArray = ["Your Image","Your Image")]
setupImages(imageArray)
func setupImages(_ images: [UIImage]){
for i in 0..<images.count {
let imageView = UIImageView()
imageView.image = images[i]
let xPosition = UIScreen.main.bounds.width * CGFloat(i)
imageView.frame = CGRect(x: xPosition, y: 0, width: scrollView.frame.width, height: scrollView.frame.height)
imageView.contentMode = .scaleAspectFit
imageArray = [UIImage(named:"yourimagename"), UIImage(named: "yourimagename")]
import UIKit
class ViewController: UIViewController {
var imageArray = [UIImage]()
...
import UIKit
class ViewController: UIViewController {
let scrollView: UIScrollView = {
let scroll = UIScrollView()
scroll.isPagingEnabled = true
scroll.showsVerticalScrollIndicator = false
scroll.showsHorizontalScrollIndicator = false
scroll.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
// Inside viewDidLoad
view.backgroundColor = UIColor.white
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = viewController()
self.window?.makeKeyAndVisible()
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: YourTabBarController())
window?.makeKeyAndVisible()
let firstViewController = firstVC()
firstViewController.tabBarItem = UITabBarItem(tabBarSystemItem: .search, tag: 0)
let secondViewController = secondVC()
secondViewController.tabBarItem = UITabBarItem(tabBarSystemItem: .more, tag: 1)
let tabBarList = [firstViewController, secondViewController]