0

When I am giving Top border to my view it is not properly working. Also I am using it in collection view cellforitematIndexPath

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "CellRID")

    cell.viewForTotalMB.addTopBorderWithColor(color: UIColor(red: 72/255, green: 175/255, blue: 230/255, alpha: 1.0), width: 1)
    cell.viewForTotalMB.layer.masksToBounds = false



    return cell!
}

I am using this extension for Borders

extension UIView {

// lbl and txtfld Border line

func addTopBorderWithColor(color: UIColor, width: CGFloat) {
    let border = CALayer()
    border.backgroundColor = color.cgColor
    border.frame = CGRect(x:0,y: 0, width:self.frame.size.width, height:width)
    self.layer.addSublayer(border)
}

}

enter image description here

1 Answers1

1

This not your solution, but it’s work to find out frame of your view or some other view overlay on view.

Run your XCode project and click on Debug View Hierarchy. You can see there your view frame and may be find issue.

enter image description here

Sagar Chauhan
  • 5,715
  • 2
  • 22
  • 56