0
我想实现一个CAPSPageMenu。不幸的是,我的视图布局存在一些问题。CAPSPageMenu Autolayout
// MARK: - Scroll menu setup
// Initialize view controllers to display and place in array
var controllerArray : [UIViewController] = []
let controller1 : EventsFeedViewController = EventsFeedViewController(nibName: "ViewControllerOne", bundle: nil)
controller1.title = "Test1"
controllerArray.append(controller1)
let controller2 : LocationsFeedViewController = LocationsFeedViewController(nibName: "ViewControllerTwo", bundle: nil)
controller2.title = "Test2"
controllerArray.append(controller2)
// Customize menu (Optional)
let parameters: [CAPSPageMenuOption] = [
.MenuItemSeparatorWidth(0.0),
.UseMenuLikeSegmentedControl(true),
.MenuItemSeparatorPercentageHeight(0.0),
.SelectedMenuItemLabelColor(UIColor(red: 18.0/255.0, green: 150.0/255.0, blue: 225.0/255.0, alpha: 1.0)),
.ScrollMenuBackgroundColor(UIColor.whiteColor()),
.SelectionIndicatorColor(UIColor(red: 18.0/255.0, green: 150.0/255.0, blue: 225.0/255.0, alpha: 1.0))
]
// Initialize page menu with controller array, frame, and optional parameters
pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0.0, 0.0, self.view.frame.width, self.view.frame.height), pageMenuOptions: parameters)
// Lastly add page menu as subview of base view controller view
// or use pageMenu controller in you view hierachy as desired
// Optional delegate
pageMenu!.delegate = self
// self.view.addSubview(pageMenu!.view)
self.addChildViewController(pageMenu!)
self.view.addSubview(pageMenu!.view)
pageMenu!.didMoveToParentViewController(self)
有没有人知道我做错了什么?
谢谢
嘿感谢您的回答。代码与我的基本相同。但我使用.xib文件并且没有故事板。我认为问题是,我的VC1和VC2的宽度= 600.000000 height = 600.000000。所以“self.view.frame.width”输出600我认为。但我不知道为什么。 – Moritz
@Moritz好吧,然后只是测试更新的代码。通过'UIScreen.mainScreen()获取屏幕宽度。bounds.size.width' –
结果看起来像这样。它只是屏幕尺寸的1/3 ... http://i.stack.imgur.com/LcPjS.png – Moritz