在UITableView的header上加阴影

来源:互联网 发布:淘宝上退款多久能到账 编辑:程序博客网 时间:2024/06/05 12:38

在header上加高度为1的阴影

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{UIView *head = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEVICE_WIDTH, 0.5)];head.layer.shadowOpacity =0.9f;head.layer.shadowRadius = 6;head.layer.shadowOffset  = CGSizeMake(1, 1);CGMutablePathRef squarePath = CGPathCreateMutable();//让图形的形状为正方形CGPathAddRect(squarePath, NULL, head.bounds);//设定阴影图形head.layer.shadowPath = squarePath;CGPathRelease(squarePath);return head;}- (CGFloat )tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{return 1;}