How to give shadow like card in iOS

后端 未结 5 1028
庸人自扰
庸人自扰 2020-12-13 05:49

I would like to give shadow effect like card similar to the image in my iOS app

I need this on UITableViewCell the image will not work for me also the the g

5条回答
  •  时光说笑
    2020-12-13 06:11

    Use a container view inside your table view cell and assign tag say 99. Keep the cell height a bit larger then your card (container view).

    and give shadow to your card view

    UIView* shadowView = [cell viewWithTag:99];
    shadowView.backgroundColor=[UIColor colorWithRed:228.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:0.5];
    [shadowView.layer setCornerRadius:5.0f];
    [shadowView.layer setBorderColor:[UIColor lightGrayColor].CGColor];
    [shadowView.layer setBorderWidth:0.2f];
    [shadowView.layer setShadowColor:[UIColor colorWithRed:225.0/255.0 green:228.0/255.0 blue:228.0/255.0 alpha:1.0].CGColor];
    [shadowView.layer setShadowOpacity:1.0];
    [shadowView.layer setShadowRadius:5.0];
    [shadowView.layer setShadowOffset:CGSizeMake(5.0f, 5.0f)];
    

提交回复
热议问题