我想知道是否有人能够成功地将UIPageViewController的角落(iBooks的动画书转动为圆角)?
我尝试了这个但无济于事:
[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];
这有点硬编码(这显然很糟糕),但我只是试图找出圆角是否有效。但是,我只得到一个非圆形的透明角落:
答案 0 :(得分:1)
添加此导入:
#import <QuartzCore/QuartzCore.h>
现在你可以使用cornerRadius:
self.notebookPages.view.layer.cornerRadius = 6;