Setting Corner Radius on UIImageView not working

前端 未结 11 1916
心在旅途
心在旅途 2020-12-22 16:15

I\'m at a bit of a loss. I\'ve used the layer property of UIView to round the corners of multiple elements in my app. However, this one UIImageView is simply not complying.

11条回答
  •  臣服心动
    2020-12-22 16:56

    -(void) viewDidAppear:(BOOL)animated{
           [super viewDidAppear:animated];
           [self setMaskTo:viewDistance 
                 byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight];
               }
    
    - (void)setMaskTo:(UIView*)view byRoundingCorners:(UIRectCorner)corners
         {
          UIBezierPath *rounded = [UIBezierPath 
                    bezierPathWithRoundedRect:view.bounds
                                                  byRoundingCorners:corners
    
                         cornerRadii:CGSizeMake(20.0, 20.0)];
    
              CAShapeLayer *shape = [[CAShapeLayer alloc] init];
              shape.frame = self.view.bounds;
             [shape setPath:rounded.CGPath];
              view.layer.mask = shape;
           }
    

提交回复
热议问题