美文网首页
swift左右侧滑

swift左右侧滑

作者: ViewController_ | 来源:发表于2018-10-21 18:18 被阅读0次
好像也得导入这个

括号外面的:

private lazy var pageTitleView: MFPageTitleView = {

        let config = MFPageTitleViewConfig()

        config.titleColor = colorWithRGB(r: 43, g: 43, b: 43)

        config.titleSelectedColor = colorWithRGB(r: 211, g: 0, b: 0)

        config.titleFont = UIFont.systemFont(ofSize: 14, weight: .regular)

        config.indicatorColor = colorWithRGB(r: 211, g: 0, b: 0)

        let pageTitleView = MFPageTitleView(frame: CGRect(x: 0, y: navHeight, width: SCREEN_WIDTH, height: 41), titles: ["","","","",""], config: config)

        pageTitleView.pageTitleViewDelegate = self

        return pageTitleView

    }()

    private lazy var pageContentView: MFPageContentView = {

        var childControllers = [UIViewController]()

        for var k in 0..<10 {

            var vc = UIViewController()

            if(0==k){

                vc = oneVC()

            }

            let red: CGFloat = CGFloat(arc4random() % 256)

            let green: CGFloat = CGFloat(arc4random() % 256)

            let blue: CGFloat = CGFloat(arc4random() % 256)

            //vc.view.backgroundColor = UIColor(red: red / 255.0, green: green / 255.0, blue: blue / 255.0, alpha: 1.0)

            childControllers.append(vc)

        }

        let pageContentViewY = pageTitleView.frame.maxY

        let pageContentView = MFPageContentView(frame: CGRect(x: 0, y: pageContentViewY, width: SCREEN_WIDTH, height: SCREEN_HEIGHT-pageContentViewY), parentVC: self, childVCs: childControllers)

        pageContentView.pageContentViewDelegate = self

        return pageContentView

    }()

viewDidLoad() 里的

//左右侧滑的

        view.backgroundColor = UIColor.white

        view.addSubview(pageTitleView)

        view.addSubview(pageContentView)

最下面:

extension ViewController: MFPageTitleViewDelegate, MFPageContentViewDelegate {

    func selectedIndexInPageTitleView(pageTitleView: MFPageTitleView, selectedIndex: Int) {

        self.pageContentView.setPageContentViewCurrentIndex(currentIndex: selectedIndex)

    }

    func pageContentViewScroll(progress: CGFloat, originalIndex: Int, targetIndex: Int) {

        self.pageTitleView.setPageTitleView(progress: progress, originalIndex: originalIndex, targetIndex: targetIndex)

    }

}

相关文章

网友评论

      本文标题:swift左右侧滑

      本文链接:https://www.haomeiwen.com/subject/lkzbzftx.html