Wednesday, July 22, 2015

bottom border for collection view

Picture a 3x3 grid, there is a high chance that the bottom row of the grid is 50% thinner than the other borders in the collectionview since there is only 1 border there(instead of 2)

            let border = CALayer()
            //width of border
            let width = CGFloat(1.0)
            //border color
            border.borderColor = UIColor(red: 216.0/255.0, green: 216.0/255.0, blue: 216.0/255.0, alpha: 1.0).CGColor

            border.frame = CGRect(x: 0, y: cell.frame.size.height - width, width:  cell.frame.size.width, height: cell.frame.size.height)


            border.borderWidth = width
            cell.layer.addSublayer(border)

            cell.layer.masksToBounds = true

No comments:

Post a Comment