LateNate LateNate - 1 year ago 165
iOS Question

Xcode 8 GM has destroyed my UI

Argh. After selecting an initial device view (6s) all my borders have completely screwed up. I used the following code:

func roundButtonLeft(button: UIButton) {

let path = UIBezierPath(roundedRect:button.bounds, byRoundingCorners:[.topLeft, .bottomLeft], cornerRadii: CGSize(width: 10, height: 10))
let maskLayer = CAShapeLayer()
maskLayer.path = path.cgPath

let frameLayer = CAShapeLayer()
frameLayer.path = path.cgPath
frameLayer.lineWidth = 1.0
frameLayer.strokeColor = UIColor.white.cgColor
frameLayer.fillColor = nil

button.layer.mask = maskLayer}

which added a border on one side of my UI buttons. This doesnt work at all now and the white border shoots off the screen.

If I discard my change it works fine before I open the storyboard and get forced to select an initial device.

Can anyone help? I've wasted a few nights on this now.

Answer Source

This took a long time to figure out. But it was to do with the button.bounds.

I fixed it by adding:


before adding the Sublayer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download