我正在使用这个MRProgress库。它以UINavigationController
作为参数。但是,在我的ViewController
(以模式形式显示)中,我自己创建了一个UINavigationBar
。
// Create the navigation bar
navigationBar = UINavigationBar(frame: CGRectMake(0, 0, self.view.frame.size.width, 44 + statusBarHeight()))
navigationBar.backgroundColor = UIColor.whiteColor()
navigationBar.delegate = self;
// Create a navigation item with a title
let navigationItem = UINavigationItem()
navigationItem.title = "New Conversation"
navigationBar.titleTextAttributes = [
NSForegroundColorAttributeName: COLORS.logo0,
NSFontAttributeName: FONTS.title
]
//Back Button
let backButton = UIButton(type: .Custom)
backButton.addTarget(self, action: #selector(CreateSessionViewController.backButtonAction(_:)), forControlEvents: UIControlEvents.TouchUpInside)
backButton.frame = CGRectMake(0, 0, 20, 20)
let cross = UIImage(named: "cross.png")
backButton.tintColor = UIColor(hex: 0xcccccc)
backButton.setImage(cross?.imageWithRenderingMode(.AlwaysTemplate), forState: UIControlState.Normal)
backButtonBar = UIBarButtonItem(customView: backButton)
navigationItem.leftBarButtonItems = [backButtonBar]
//Add nav bar
navigationBar.items = [navigationItem]
self.view.addSubview(navigationBar)
如何将此导航栏作为参数传递给库?该库支持以下内容:
MRNavigationBarProgressView(forNavigationController: UINavigationController!)
最佳答案
如果可以的话,您可以模态地显示一个UINavigationController
来包装该ViewController
。
关于ios - 如何将我的UINavigationBar转换为UINavigationController(供此库使用)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37426092/