iOS控件周围阴影

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

    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

你可能感兴趣的:(iOS控件周围阴影)