Horizontal padding between UIPageViewController child view controllers

后端 未结 3 1633
半阙折子戏
半阙折子戏 2021-02-08 00:49

I am using UIPageViewController to display images that are embedded in child view controllers.

NSDictionary *options = [NSDictionary dictionaryWithObject: [NSNum         


        
相关标签:
3条回答
  • 2021-02-08 01:14

    With Swift, you can 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.

    0 讨论(0)
  • 2021-02-08 01:19

    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

    0 讨论(0)
  • 2021-02-08 01:27

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

    0 讨论(0)
提交回复
热议问题