-2

我只需要舍入UIView. 我正在尝试使用以下代码:

UIBezierPath *maskEmailPath = [UIBezierPath bezierPathWithRoundedRect:self.emailandAccessView.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(10.0, 10.0)];
CAShapeLayer *maskEmailLayer = [CAShapeLayer layer];
maskEmailLayer.frame = self.myview.bounds;
maskEmailLayer.path = maskEmailPath.CGPath;
self.myview.layer.mask = maskEmailLayer;

但它隐藏了该视图中的所有内容。谁能帮帮我吗。

4

1 回答 1

1

这就是你的做法。

  CALayer *capa = self.view.layer;
  CGRect bounds = capa.bounds;
  UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bounds
                                                 byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
                                                       cornerRadii:CGSizeMake(5.0, 5.0)];

  CAShapeLayer *maskLayer = [CAShapeLayer layer];
  maskLayer.frame = bounds;
  maskLayer.path = maskPath.CGPath;

  [capa addSublayer:maskLayer];
  capa.mask = maskLayer;
于 2012-12-28T11:23:57.883 回答