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

n.evermind
  • 11,944
  • 19
  • 78
  • 122
  • have you tried to set the `layer.cornerRadius` property of `UIView` of the `UIViewController` pages? – holex Aug 13 '12 at 21:21
  • I just tried that, only effected the corners pre turn-animation. I'm on iOS5 though. Might be different in iOS6. – Marty Aug 14 '12 at 13:44
  • 1
    I guess that this effect is managed by OpenGL not Core Animation, I don't think is possible. – Andrea Aug 16 '12 at 14:53
  • Probably you should create a new image with rounded corners using Quartz, but this should be' done before adding them to the page view controller – Andrea Aug 16 '12 at 18:36
  • 1
    iOS framework puts in a shadow, so when you have any transparent areas on your pages, the shadow shows through. I played around with this for hours and never found a way to change this. – jjxtra Apr 18 '13 at 20:42

1 Answers1

1

Add this import:

#import <QuartzCore/QuartzCore.h>

Now you can use cornerRadius:

self.notebookPages.view.layer.cornerRadius = 6;
Niralp
  • 235
  • 2
  • 4