我用阴影将阴影添加到视图中corners并且它有效.但是当frame视图更改时,shadow根据视图不会改变其大小.我尝试过以下方法:
-(void)addShadow:(UIView *)view withCornerRad : (int)radius{
view.clipsToBounds = YES;
CALayer *ViewLayer = view.layer;
[ViewLayer setMasksToBounds:NO ];
ViewLayer.shadowColor = [UIColor lightGrayColor].CGColor;
ViewLayer.shadowOpacity = 1.0 ;
ViewLayer.shadowRadius = 2.0 ;
ViewLayer.shadowOffset = CGSizeMake( 0 , 0 );
ViewLayer.cornerRadius = radius;
ViewLayer.shadowPath = [UIBezierPath bezierPathWithRect:view.bounds].CGPath;
}
Run Code Online (Sandbox Code Playgroud)

