OGeek|极客世界-中国程序员成长平台

标题: ios - 为 TableView 部分 iOS 添加背景 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:35
标题: ios - 为 TableView 部分 iOS 添加背景

我有一个包含动态多行的部分,我需要将所有部分与背景分开,如下图所示。

特别是所有部分的边界线。请让我知道我怎样才能使它成为可能。

- (NSInteger)numberOfSectionsInTableViewUITableView *)tableView;
{
    return  ProductArray.count;  
}

- (NSInteger)tableViewUITableView *)tableView numberOfRowsInSectionNSInteger)section
{
    NSArray *arr = [ProductArray objectAtIndex:section];
    return arr.count;    
}

请引用这里

image .

我尝试添加页眉和页脚,但我不明白如何为整个部分添加矩形框图像。



Best Answer-推荐答案


在输出该 View 后将 View 放入您的单元格中。并使用 cellForRowAtIndexPath 这个方法。

    - (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath
 {
    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier"TableViewCell" forIndexPath:indexPath];
                [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    cell.viewBackGround.backgroundColor = [UIColor redColor];
    return cell;
}

关于ios - 为 TableView 部分 iOS 添加背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45973228/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4