iOS控件周围阴影

2021-10-21  本文已影响0人  见惯不怪

废话不多说,直接上代码:

    UIView  * shadowView = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 200, 100)];
    shadowView.backgroundColor = [UIColor whiteColor];
    shadowView.layer.shadowColor =[UIColor grayColor].CGColor;  // 阴影颜色
    shadowView.layer.shadowOpacity = 1; // 阴影透明度,默认0
    shadowView.layer.shadowOffset = CGSizeZero; // 设置偏移量0,代表四周都有阴影
    shadowView.layer.shadowRadius = 20.0; // 阴影半径,默认是 3
    shadowView.layer.cornerRadius = 50;
    shadowView.layer.masksToBounds = NO;
    [self.view addSubview:shadowView];

效果如下:


image.png
上一篇 下一篇

猜你喜欢

热点阅读