UITableView 阴影不正确(未对齐)

UITableView Shadow not coming properly (mis aligned)

我正在尝试将底部阴影添加到 UITableViewCell 及其即将出现但未对齐。这是我的代码,我也上传了我的截图

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 125;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];

    if(indexPath.row==0){
    cell.contentView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell1"]];
    // Configure the cell...
    }else if(indexPath.row==1){
    cell.contentView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell2"]];
    }else if(indexPath.row==2){
    cell.contentView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell3"]];

    }else if(indexPath.row==3){
    cell.contentView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell4"]];

    }else {
    cell.contentView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell5"]];

    }
    cell.layer.shadowColor = [[UIColor blackColor] CGColor];
    cell.layer.shadowOpacity = 0.5;
    cell.layer.shadowOffset = CGSizeMake(0, 1);
    return cell;
}

截图

如何正确对齐底部的阴影?

请更新您的代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
UIImageView *av = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 277, 58)];
av.backgroundColor = [UIColor clearColor];
av.opaque = NO;

if(indexPath.row==0){

// Configure the cell...
    av.image = [UIImage imageNamed:@"cell1"];
    cell.backgroundView = av;
}else if(indexPath.row==1){
    av.image = [UIImage imageNamed:@"cell2"];
    cell.backgroundView = av;
}else if(indexPath.row==2){
    av.image = [UIImage imageNamed:@"cell3"];
    cell.backgroundView = av;
}else if(indexPath.row==3){
    av.image = [UIImage imageNamed:@"cell4"];
    cell.backgroundView = av;
}else {
    av.image = [UIImage imageNamed:@"cell5"];
    cell.backgroundView = av;
}

return cell;

}