Horizontal padding between UIPageViewController child view controllers

£可爱£侵袭症+ 提交于 2019-12-03 02:24:09

check UIPageViewController init method

- (id)initWithTransitionStyle:(UIPageViewControllerTransitionStyle)style navigationOrientation:(UIPageViewControllerNavigationOrientation)navigationOrientation options:(NSDictionary *)opt

you can pass your inter page space value to opt in UIPageViewControllerOptionInterPageSpacingKey

With Swift, you would use initWithTransitionStyle:navigationOrientation:options: initializer and pass a value to UIPageViewControllerOptionInterPageSpacingKey in your options parameter to set a space between pages.

As an example, the following code shows how to implement it with Swift 2.2:

let optionsDict = [UIPageViewControllerOptionInterPageSpacingKey : 20]

let pageViewController = UIPageViewController(transitionStyle: .Scroll,
    navigationOrientation: .Horizontal,
    options: optionsDict)

Note that the UIPageViewController class reference states about UIPageViewControllerOptionInterPageSpacingKey:

The value should be a CGFloat wrapped in an instance of NSNumber.

However, a Dictionary of type [String : Int], as shown in the previous code, also works.

Select the UIPageViewController from the Storyboard. Inside the Attributes Inspector there is an option for setting the Page Spacing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!