gpt4 book ai didi

ios - 如何在 UITableView 中只设置右边框?

转载 作者:行者123 更新时间:2023-12-01 17:31:30 25 4
gpt4 key购买 nike

我只想在 UITableView 中设置右边框?

到目前为止,我已经尝试过以下代码。但它在整个表格中设置边框,就像在mac中一样,但我想实现它应该只设置右边框: -

self.tableView.layer.borderWidth = 1.0;

最佳答案

而不是使用图层,您可以将 View 添加到您想要大小的单元格的 contentView 中,这添加了 1px 的边框:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

...

UIView *right = [[UIView alloc] initWithFrame:CGRectMake(319, 0, 1, cell.frame.size.height)];
right.backgroundColor = [UIColor redColor];

[cell.contentView addSubview:right];

关于ios - 如何在 UITableView 中只设置右边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20287711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com