头部滚动 viewcontroller


//  ViewController.swift

import UIKit
private let glt_iphoneX = (UIScreen.main.bounds.height ==812.0)
classViewController:UIViewController{
private lazy var viewControllers: [UIViewController] = {

       let one = oneVC()

       let two = threeVc()

       let three = twoVc()

       let four = fourVc()

       return[one, two, three, four]

   }()
    private lazy var titles: [String] = {

        return["热门","推荐","科技","游戏"]

    }()
    private lazy var layout:LTLayout= {

        letl ayout = LTLayout()

        layout.sliderWidth =50

        layout.titleMargin =10.0

        // (屏幕宽度 - 标题总宽度 - 标题间距宽度) / 2 = 最左边以及最右边剩余

        let lrMargin = (view.bounds.width - (CGFloat(titles.count) * layout.sliderWidth + CGFloat(titles.count -1) * layout.titleMargin)) *0.5

        layout.lrMargin = lrMargin

        layout.isAverage =true

        return layout

    }()
    private lazy va rpageView:LTPageView= {

        let statusBarH = UIApplication.shared.statusBarFrame.size.height

        let Y:CGFloat = statusBarH +44

        let H:CGFloat =  glt_iphoneX ? (view.bounds.height - Y -34) : view.bounds.height - Y

        let pageView = LTPageView(frame: CGRect(x:0, y: Y, width: view.bounds.width, height: H), currentViewController:self, viewControllers: viewControllers, titles: titles, layout: layout)

        pageView.isClickScrollAnimation =true

        return pageView

    }()

    override func viewDidLoad() {

        super.viewDidLoad()

        view.backgroundColor = UIColor.white

        automaticallyAdjustsScrollViewInsets =false

        view. addSubview(pageView)

        //        simpleManagerConfig()



        pageView.didSelectIndexBlock = {(_, index)in

            print("pageView.didSelectIndexBlock", index)

        }

    }

}

你可能感兴趣的:(头部滚动 viewcontroller)