Проблема дизайна при применении углового радиуса только к верхней и нижней ячейке - PullRequest
0 голосов
/ 11 мая 2018

enter image description here

Я взял заголовок раздела UITableview и другую ячейку для отображения содержимого, но когда дело доходит до углового радиуса, как мы можем добиться такого расположения без каких-либо проблем.

Я пытался указать угловой радиус заголовка таблицы для topLeft, topRight и последней ячейки bottomLeft, bottomRight, но у меня это не сработало.

 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

        guard let headerView = tableView.dequeueReusableCell(withIdentifier: "headerCell") as? headerCell else { return UIView() }

        headerView.labelTaskName.text = arrayTaskLists[section].first?.outcome_title
        headerView.viewContainerHeader.roundCorners([.topRight,.topLeft], radius: 10.0)
        headerView.viewContainerHeader.layoutSubviews()
        headerView.btnHeaderViewCell.tag = section
        headerView.delegate = self

        return headerView
    }

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 44
    }

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier.TaskInformationCell) as! TaskInformationCell

        cell.infoView.roundCorners([.bottomLeft,.bottomRight], radius: 10.0)
        cell.infoView.layoutSubviews()
    }

Спасибо за вашу помощь.

Ответы [ 2 ]

0 голосов
/ 14 мая 2018

использовать ячейку таблицы Disclouser для ячеек и заголовок раздела для верхнего заголовка

0 голосов
/ 11 мая 2018

Вы можете изменить de backgroundView TableViewCell, создать подкласс UIView и изменить класс слоя:

class BackgroundView: UIView 
{
    class var layerClass: AnyClass
    {
        return CAShapeLayer.self
    }
}

позже в cellForRowAtIndexPath вы сделаете что-то вроде этого:

private var CellIdentifier = "CustomCell"

let cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier, for: indexPath) as? CustomCell
let frame: CGRect? = cell?.backgroundView.frame
cell?.backgroundView = BackgroundView(frame: frame ?? CGRect.zero)

var corner: CGFloat = 20.0
var path = UIBezierPath(roundedRect: cell?.backgroundView.bounds ?? CGRect.zero, byRoundingCorners: .allCorners, cornerRadii: CGSize(width: corner, height: corner))
var shapeLayer = cell?.backgroundView.layer as? CAShapeLayer

shapeLayer?.path = path.cgPath
shapeLayer?.fillColor = cell?.textLabel.backgroundColor?.cgColor
shapeLayer?.strokeColor = UIColor.lightGray.cgColor
shapeLayer?.lineWidth = 1.0

return cell
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...