iOS——四周阴影

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:37   3682   0
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];

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP