enter image description here

There is a KeyboardView - keyboard with a button KeboardButton. Each KeboardButton has a border of 0.5 pixels. The keys are in contact with each other closely, respectively, it turns out "common" border width of 1px.

class KeyboardButton: UIControl { override init(frame: CGRect) { super.init(frame: frame) layer.borderWidth = 0.5 layer.borderColor = UIColor.black.cgColor layer.masksToBounds = true } } 

The problem is that the vertical and horizontal lines are in different colors. At first I thought it was an optimus deception. Then I took a screenshot, opened it in Photoshop and checked the colors with a pipette, it turned out that they are really different.

Why is happening and how to fix it?

enter image description here

    1 answer 1

    Probably something related to smoothing. Shadow with a certain radius is also not accurate for pixels.

    Do not border, but indent the desired distance between the buttons, and paint the view under the buttons in the desired color.