gpt4 book ai didi

ios - Xcode 8 GM 破坏了我的 UI

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:57:25 24 4
gpt4 key购买 nike

唉。选择初始设备 View (6 秒)后,我所有的边框都完全搞砸了。我使用了以下代码:

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}

它在我的 UI 按钮的一侧添加了边框。这现在根本不起作用,白色边框从屏幕上弹出。

如果我放弃我的更改,它会在我打开 Storyboard并被迫选择初始设备之前正常工作。

有人可以帮忙吗?我现在已经在这上面浪费了几个晚上。

最佳答案

这花了很长时间才弄清楚。但它与 button.bounds 有关。

我通过添加修复了它:

button.layoutIfNeeded()

在添加子层之前。

关于ios - Xcode 8 GM 破坏了我的 UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39604641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com