gpt4 book ai didi

ios - 如何将 UILabel 重新定位在与另一个 UILabel 完全相同的位置

转载 作者:行者123 更新时间:2023-11-28 14:54:27 25 4
gpt4 key购买 nike

我正在尝试将 UILabel 重新定位在另一个 UILabel 上(相同位置)。它没有将自己精确定位在目标 UILabel 上。

见下面的代码

let element1yPosition = element1.frame.origin.y. // Element 1 y Position

let element2yPosition = element2.frame.origin.y. // Element 2 y Position

UIView.animate(withDuration: 1.0, animations: {

element1.frame.origin.y = element2yPosition // Repositioning stage.
//Fails because Element 1 doesn't re-position itself in the exact same position as Element 2 as required.

})

最佳答案

你能试试吗

UIView.animate(withDuration: 1.0, animations: {

element1.frame = element2.frame

})

关于ios - 如何将 UILabel 重新定位在与另一个 UILabel 完全相同的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49505561/

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