简体   繁体   English

Xcode 8 GM破坏了我的用户界面

[英]Xcode 8 GM has destroyed my UI

Argh. 哎呀。 After selecting an initial device view (6s) all my borders have completely screwed up. 选择初始设备视图(6s)后,我的所有边框都完全弄乱了。 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.addSublayer(frameLayer)
    button.layer.mask = maskLayer}

which added a border on one side of my UI buttons. 在我的UI按钮的一侧添加了边框。 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. 我现在在这上浪费了几个晚上。

This took a long time to figure out. 这花了很长时间才弄清楚。 But it was to do with the button.bounds. 但这与button.bounds有关。

I fixed it by adding: 我通过添加以下内容进行修复:

button.layoutIfNeeded()

before adding the Sublayer. 在添加子层之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM