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の高さ= 600.000000のサイズを持っていると思います。そして、 "self.view.frame.width"出力600と思います。しかし、なぜ私はアイデアを持っていません。 – Moritz
@Moritz Okは、更新されたコードをテストします。 'UIScreen.mainScreen()。bounds.size.width'でスクリーン幅を取得します –
結果は次のようになります。それは画面サイズの1/3しかありません... http://i.stack.imgur.com/LcPjS.png – Moritz