UIView * bgView = [[UIView alloc]init];
bgView.backgroundColor = [UIColor whiteColor];
bgView.frame = CGRectMake(100, 100, 100, 100);
bgView.layer.shadowColor = [UIColor grayColor].CGColor;
bgView.layer.shadowOffset = CGSizeZero; // 设置偏移量为 0 ,四周都有阴影
bgView.layer.shadowRadius = 20.0; //阴影半径,默认 3
bgView.layer.shadowOpacity = 0.2; //阴影透明度 ,默认 0
// bgView.layer.borderWidth = 0.5;
// bgView.layer.borderColor = [UIColor blackColor].CGColor;
bgView.layer.cornerRadius = 10;
bgView.layer.masksToBounds = NO;
bgView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:bgView.bounds cornerRadius:bgView.layer.cornerRadius].CGPath;
[self.view addSubview:bgView];
|