gpt4 book ai didi

ios - 滚动时隐藏导航栏的页面菜单

转载 作者:行者123 更新时间:2023-11-28 12:39:49 24 4
gpt4 key购买 nike

我想要导航栏扩展中的两个菜单,并在滚动时隐藏除扩展之外的导航栏。

我能够用 PageMenu 实现菜单“PageMenu”并通过AMScrollingNavbar隐藏导航栏

enter image description here

但我现在面临的问题是 Nav bar 隐藏了,但是 views 并没有随着 nav bar 一起移动

func loadControllers(){

let storyboard = UIStoryboard(name: "Main", bundle: nil)

let topViewController = storyboard.instantiateViewControllerWithIdentifier("TopNewsController") as!
TopNewsController

topViewController.title = "TOP"
controllerArray.append(topViewController)

let briefViewController = storyboard.instantiateViewControllerWithIdentifier("BriefViewController") as!
BriefViewController

briefViewController.title = "BRIEFS"
controllerArray.append(briefViewController)


let videoViewController = storyboard.instantiateViewControllerWithIdentifier("VediosViewController") as!
VediosViewController

videoViewController.title = "VIDEOS"
controllerArray.append(videoViewController)


// Customize menu
parameters = [
.ScrollMenuBackgroundColor(UIColor.navigationBarColor()),
.ViewBackgroundColor(UIColor(red: 20.0/255.0, green: 20.0/255.0, blue: 20.0/255.0, alpha: 1.0)),
.SelectionIndicatorColor(UIColor.whiteColor()),
.BottomMenuHairlineColor(UIColor(red: 70.0/255.0, green: 70.0/255.0, blue: 80.0/255.0, alpha: 1.0)),
.MenuItemFont(UIFont(name: "HelveticaNeue-Bold", size: 14.0)!),
.MenuHeight(expressTribuneUtilities.convertIphone6ToIphone5(48)),
.MenuItemWidth(90.0),
.CenterMenuItems(true)
]


AppDelegate.getInstatnce().nav = self.navigationController as! ScrollingNavigationController
AppDelegate.getInstatnce().nav.scrollingNavbarDelegate = self


// Initialize scroll menu
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 64.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)

self.view.addSubview(pageMenu!.view)

}

enter image description here

从添加到菜单的类中调用 Scroll 方法

        AppDelegate.getInstatnce().nav.followScrollView(tableMainView, delay: 0.5)

最佳答案

    AppDelegate.getInstatnce().nav = self.navigationController as! ScrollingNavigationController
AppDelegate.getInstatnce().nav.scrollingNavbarDelegate = self

将这两行更改为这样它不会起作用,因为您正在为其他实例而不是导航设置委托(delegate)。

        let navController = AppDelegate.getInstatnce().window?.rootViewController as! ScrollingNavigationController
navController.scrollingNavbarDelegate = self

在您的 Controller 中实现委托(delegate)并设置您的 View 原点 w.r.t ScrollView 。

关于ios - 滚动时隐藏导航栏的页面菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39718419/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com