相关疑难解决方法(0)

UIEdgeInsetsMake在单元格上创建一个奇怪的乐队,我不知道如何解决它

我正在尝试将UIEdgeInsetsMake我的单元格的背景设置为渐变.我已尝试过多种方法让它发挥作用,但无论我使用什么,总会出现问题.

我只是有两个静态细胞,在那里我试图设置他们backgroundViewwillDisplayCell:.我有顶部,底部和中间单元的单独图像,但由于我有两个单元格,我只需要顶部和底部.这些是这些图像:

最佳

在此输入图像描述

底部

在此输入图像描述

底部顶部有一条缺失线,因此它们之间没有2pt线.我稍微调整了底部的高度以补偿(高1pt).这些图像是44x44pt.

我把它们设置如下:

- (void)tableView:(UITableView *)tableView 
  willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        UIImageView *topCellBackgroundImageView = 
        [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"grouped-cell-bg-top"]
               resizableImageWithCapInsets:UIEdgeInsetsMake(5.0, 5.0, 5.0, 5.0)]];
        cell.backgroundView = topCellBackgroundImageView;
    }
    // If it's the last row
    else if (indexPath.row == ([tableView numberOfRowsInSection:0] - 1)) {
        UIImageView *bottomCellBackgroundImageView = 
        [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"grouped-cell-bg-bottom"] 
               resizableImageWithCapInsets:UIEdgeInsetsMake(5.0, 5.0, 5.0, 5.0)]];
        cell.backgroundView = bottomCellBackgroundImageView;
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
Run Code Online (Sandbox Code Playgroud)

这不行.正如您在下面的图片中所看到的,在顶部单元格中,整个单元格中有一条1pt白色"带",看起来非常难看.我不知道为什么会这样.

在此输入图像描述

所以我改变了它的topCellBackgroundView边缘插入(5.0, 5.0, …

objective-c uitableview uiimageview ios uiedgeinsets

9
推荐指数
1
解决办法
2521
查看次数