问题描述
我正在尝试让这个 pod 在我的项目中工作,但我一直在理解这部分是如何工作的:
I'm trying to get this pod working in my project and I'm stuck on understanding how this bit works :
https://github.com/uacaps/PageMenu
// Create variables for all view controllers you want to put in the
// page menu, initialize them, and add each to the controller array.
// (Can be any UIViewController subclass)
// Make sure the title property of all view controllers is set
// Example:
var controller : UIViewController = UIViewController(nibName: "controllerNibName", bundle: nil)
controller.title = "SAMPLE TITLE"
controllerArray.append(controller)
我看到有人说我需要使用我在情节提要中设置的情节提要 ID 来初始化视图控制器,但是当我尝试执行诸如
I've seen things that say I need to initialize the view controller with the storyboard ID I set in the storyboard , but when I try to do somethign like
let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") as! UIViewController
self.presentViewController(vc, animated: true, completion: nil)
但老实说,我不知道该放在哪里/何时/如果那是什么
But to be honest I have no idea where/when to put that/ if that's even what
这个想法是为页面菜单制作一组视图控制器,以在顶部显示标签栏,但我不确定如何从我在故事板中制作的视图中制作该数组.
The idea is to make an array of view controllers for the pagemenu to display with the tab bar up at the top, but I'm not sure how exactly to make that array from views I'm making in the storyboard.
推荐答案
给你.PageMenu 是超级酷和超级可定制的.玩得开心.希望这可以帮助.如果您遇到任何其他问题,请告诉我.
Here you go. PageMenu is super cool and super customizable. Have fun. Hope this helps. Let me know if you run into any other problems.
var pageMenu: CAPSPageMenu?
override func viewDidLoad() {
super.viewDidLoad()
setupPages()
}
func setupPages() {
var controllerArray: [UIViewController] = []
let firstVC = FirstViewController()
firstVC.title = "FirstOne"
let secondVC = SecondViewController()
secondVC.title = "Another One"
let thirdVC = ThirdViewController()
thirdVC.title = "And Another One"
controllerArray.append(firstVC)
controllerArray.append(secondVC)
controllerArray.append(thirdVC)
// a bunch of random customization
let parameters: [CAPSPageMenuOption] = [
.ScrollMenuBackgroundColor(UIColor.quotesBackgroundColor()),
.ViewBackgroundColor(UIColor.quotesBackgroundColor()),
.SelectionIndicatorColor(UIColor.peterRiverColor()),
.BottomMenuHairlineColor(UIColor(red: 70.0/255.0, green: 70.0/255.0, blue: 80.0/255.0, alpha: 1.0)),
.MenuHeight(40.0),
.MenuItemWidth(100.0),
.CenterMenuItems(true),
.SelectedMenuItemLabelColor(UIColor.blueColor())
]
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)
self.view.addSubview(pageMenu!.view)
}
这篇关于实现 PageMenu/从故事板初始化视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!