gpt4 book ai didi

ios - 如何通过 Swift 找到 UITextField 的位置?

转载 作者:搜寻专家 更新时间:2023-10-31 21:53:37 24 4
gpt4 key购买 nike

我如何通过 Swift 找到 UITextField 的位置?

我想知道我的 UITextField 和 View 底部位置之间的距离。

谢谢!

最佳答案

试试这个,

获取您的文本字段在您的程序中的位置。

println("Your textfiled position : \(textfiled.frame)") // (x,y,width,height)

在程序中获取 BottowView 位置。

println("BottomView position : \(bottomview.frame)") // (x,y,width,height)

获取两个位置之间的距离。

println("Distance x:(textfiled.frame.origin.x - bottomview.frame.origin.x) ")
println("Distance y:(textfiled.frame.origin.y - bottomview.frame.origin.y) ")
println("Distance width:(textfiled.frame.size.width - bottomview.frame.size.width) ")
println("Distance height:(textfiled.frame.size.height - bottomview.frame.size.height) ")

关于ios - 如何通过 Swift 找到 UITextField 的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31518824/

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