【发布时间】:2016-10-16 12:56:06
【问题描述】:
我用圆角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;
}
【问题讨论】:
-
每次更改视图框架时都必须更新视图阴影
标签: ios dynamic uiview shadow rounded-corners