gpt4 book ai didi

ios - Swift 3/如何将 Root 的 UINavigationBar 与 UIViewController 的 UINavigationBar 重叠

转载 作者:行者123 更新时间:2023-11-28 16:06:41 27 4
gpt4 key购买 nike

我正在尝试从 Tinder 重新创建导航行为。为此,我翻译了一个 Framework delivering the NavigationBar进入 Swift 3。

测试应用程序非常简单。我创建了一个测试 git project , 如果有人感兴趣的话。

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
var controller: SLPagingViewSwift!
var nav: UINavigationController?
var home: ViewController?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {


window = UIWindow(frame: UIScreen.main.bounds)
let orange = UIColor(red: 255/255, green: 69.0/255, blue: 0.0/255, alpha: 1.0)
let gray = UIColor(red: 0.84, green: 0.84, blue: 0.84, alpha: 1.0)

let stb = UIStoryboard(name: "Main", bundle: nil)
self.home = stb.instantiateViewController(withIdentifier: "ViewController") as? ViewController
let vc2 = ViewController()
vc2.view.backgroundColor = .red
let vc3 = ViewController()
vc3.view.backgroundColor = .blue


var homeBtn = UIImage(named: "profile")
homeBtn = homeBtn?.withRenderingMode(.alwaysTemplate)
var vc2Btn = UIImage(named: "gear")
vc2Btn = vc2Btn?.withRenderingMode(.alwaysTemplate)
var vc3Btn = UIImage(named: "chat")
vc3Btn = vc3Btn?.withRenderingMode(.alwaysTemplate)

let items = [UIImageView(image: homeBtn),
UIImageView(image: vc2Btn),
UIImageView(image: vc3Btn)]

let controllers = [self.home!,
vc2,
vc3] as [UIViewController]

self.controller = SLPagingViewSwift(items: items, controllers: controllers, showPageControl: false)

self.controller.pagingViewMoving = ({ subviews in
if let imageViews = subviews as? [UIImageView] {
for imgView in imageViews {
var c = gray
let originX = Double(imgView.frame.origin.x)

if (originX > 45 && originX < 145) {
c = self.gradient(originX, topX: 46, bottomX: 144, initC: orange, goal: gray)
}
else if (originX > 145 && originX < 245) {
c = self.gradient(originX, topX: 146, bottomX: 244, initC: gray, goal: orange)
}
else if(originX == 145){
c = orange
}
imgView.tintColor = c
}
}
})

self.nav = UINavigationController(rootViewController: self.controller)
self.window?.rootViewController = self.nav
self.window?.backgroundColor = UIColor.black
self.window?.makeKeyAndVisible()

return true

}

在我的 UIViewController 中,我想将一个新的 UIViewController 插入 UINavigationController 堆栈 (以具有后退按钮和向后滑动),单击单元格后。

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let stb = UIStoryboard(name: "Main", bundle: nil)
let vc = stb.instantiateViewController(withIdentifier: "SegueVC")
let appDelegate = UIApplication.shared.delegate as! AppDelegate

appDelegate.controller?.navigationController?.pushViewController(vc, animated: true)
//appDelegate.nav?.pushViewController(vc, animated: true)
}

问题是,SegueVC 与根具有相同的UINavigationBar

enter image description here

基本上,我希望 SegueVCUINavigationBar 与 Root Controller 的栏重叠以具有此功能:

enter image description here

如果我将 SegueVC 推到 controllernav 上没有任何区别。

appDelegate.controller?.navigationController?.pushViewController(vc, animated: true)
//appDelegate.nav?.pushViewController(vc, animated: true)

AppDelegate中的结构如图:navwindowrootViewControllerwindowUINavigationController var Controller :SLPagingViewSwift!

self.nav = UINavigationController(rootViewController: self.controller)
self.window?.rootViewController = self.nav
self.window?.backgroundColor = UIColor.black
self.window?.makeKeyAndVisible()

我正在考虑在导航堆栈之外呈现 SegueVC 动画,但后来我缺少内置后退按钮和向后滑动手势。我有哪些选择?非常感谢您的帮助。

最佳答案

您可以通过为您的 mainVC 设置一个容器并相应地移动它来做到这一点...我相信推特动画很容易实现。我在我的项目中使用了相同类型的动画过渡。

我强烈建议在giithub中检查这个项目 https://github.com/evnaz/ENSwiftSideMenu并通过此链接查看我的答案 Change Status Bar Color in Real Time

如果您想从您的帖子中获得您的第一个截屏视频。我相信你可以很容易地隐藏你的 statusBar 和 navigationBar。并在导航栏位置的顶部放置一个 UIView 检查我的答案 Swift Navigation bar background color white does not work然后放置一个 uiview lager,然后放置 storyBoard,例如 view.frame.width + 100(无论大小适合您)并在检测到 swipeGesture 时使用 UIView(您可以使用容器)偏移位置。

检查与 twitter 动画相关的链接 https://github.com/ThornTechPublic/InteractiveSlideOutMenu https://github.com/ThornTechPublic/LeftSlideoutMenu

注意:以上,根据我和问题所有者之间的早期对话回答。

关于ios - Swift 3/如何将 Root 的 UINavigationBar 与 UIViewController 的 UINavigationBar 重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40187545/

27 4 0
文章推荐: javascript - 将
  • in
  • Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com