How could I add a shadow to a grouped UITableView (as seen in the official twitter app)?

前端 未结 5 812
攒了一身酷
攒了一身酷 2021-01-30 17:27

I have a standard grouped table view. I would like to add a shadow around it (i.e. around the edge of each tableview section) - if you are not sure what I mean, then see the off

5条回答
  •  天命终不由人
    2021-01-30 17:59

    You could always set a ShadowPath like this:

    myView.layer.shadowOpacity = 0.8;
    myView.layer.shadowRadius = 5.0;
    myView.layer.shadowOffset = CGSizeZero;
    myView.layer.shadowPath = [UIBezierPath bezierPathWithRect:myView.layer.bounds].CGPath;
    

    Note that this requires QuartzCore or CoreGraphics, cannot remember well.

    In this article there are a lot of shadow paths: http://nachbaur.com/blog/fun-shadow-effects-using-custom-calayer-shadowpaths

提交回复
热议问题