4

I was wondering if anyone was ever successful in changing the corners of an UIPageViewController (the fancy book turning animation of iBooks) to rounded corners?

I tried this but to no avail:

[self.notebookPages setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];
self.notebookPages.dataSource = self.pageModelController;
self.notebookPages.doubleSided = NO;
[self addChildViewController:self.notebookPages];

    // mask

    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    UIBezierPath *roundedPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 332, 480)
                                                      byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight
                                                            cornerRadii:CGSizeMake(15.f, 15.f)];
    maskLayer.fillColor = [[UIColor whiteColor] CGColor];
    maskLayer.backgroundColor = [[UIColor clearColor] CGColor];
    maskLayer.path = [roundedPath CGPath];

self.notebookPages.view.layer.mask = maskLayer;

[self.notebookScrollNavigationController.notebook.pages addSubview:self.notebookPages.view];

self.notebookPages.view.frame = CGRectMake(0, 0, 332, 480);
[self.notebookPages didMoveToParentViewController:self];

This is all a bit hardcoded (which is obviously bad) but I was just trying to find out if rounded corners would work. However, I only get a non-rounded transparent corner:

enter image description here

4

1 回答 1

1

添加此导入:

#import <QuartzCore/QuartzCore.h>

现在您可以使用cornerRadius:

self.notebookPages.view.layer.cornerRadius = 6;
于 2013-01-19T13:54:19.720 回答