【问题标题】:How to get rounded corners only on bottom of the blurview with clear color on iOS?如何在iOS上仅在具有清晰颜色的模糊视图底部获得圆角?
【发布时间】:2016-08-09 02:23:03
【问题描述】:

我将模糊视图放在 UITableViewCell 中。所以单元格的背景颜色设置为清除颜色。但我也希望对特定的角进行圆角处理。

我遇到了this solution 获得圆角。

  1. 创建一个 CAShapeLayer。
  2. 创建具有特定角和角半径的 UIBezierPath。
  3. 将其应用到 CAShapeLayer 并添加为目标视图层的蒙版。

但这仅在视图具有背景颜色时才有效。我只想用清晰的颜色将特定的角弄圆。

提前致谢。

【问题讨论】:

  • 试试这个做角,tableView.layer.cornerRadius = 10 tableView.layer.masksToBounds = true
  • @ChandanPrajapati 感谢您的建议。但它会绕过所有的角落。但我只希望特定的角(比如 bottomLeft 和 bottomRight)是圆角的。
  • 关注此链接try link
  • @ChandanPrajapati 再次感谢。我试过那个解决方案。但是当我在 UItableviewCell 上执行此操作时,我添加的模糊效果消失了。我想要那种模糊效果以及特定的圆角,比如锁定屏幕上的通知。

标签: ios uibezierpath rounded-corners cashapelayer uivisualeffectview


【解决方案1】:

试试这个

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.viewOutlet.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(10.0, 10.0)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.view.bounds;
maskLayer.path  = maskPath.CGPath;
self.viewOutlet.layer.mask = maskLayer;  

【讨论】:

    猜你喜欢
    • 2022-11-22
    • 1970-01-01
    • 2020-11-05
    • 1970-01-01
    • 2017-02-23
    • 2018-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多