在应用程序中,我将 UINavigationBar 子类化,并且作为我的 TitleView,我正在设置(在视图控制器中)自定义 UIView
[self.playButton setBackgroundColor:[UIColor yellowColor]];
[self.navigationItem setTitleView:self.playButton];
此视图 (playButton) 的底部边缘应该是弯曲的。不仅是角落,机器人整个底边。为了达到这种效果,我正在使用以下代码:
CAShapeLayer *maskLayer = [CAShapeLayer layer];
UIBezierPath *path = [[UIBezierPath alloc] init];
[path addCurveToPoint:CGPointMake(self.playButton.frame.size.width, self.playButton.frame.size.height) controlPoint1:CGPointMake(0, self.playButton.frame.size.height) controlPoint2:CGPointMake(self.playButton.frame.size.width, 60)];
maskLayer.path = path.CGPath;
self.playButton.layer.mask = maskLayer;
但在那段代码之后,我的 UIView (playButton) 消失了!这是应用 UIView 弯曲底部边缘的正确方法吗?
它应该看起来像这样:http: //i.imgur.com/51UIQsE.png