gpt4 book ai didi

ios - 如何制作一个自动调整的UiTextField Frame

转载 作者:行者123 更新时间:2023-11-30 12:16:43 25 4
gpt4 key购买 nike

我正在尝试制作一个可根据屏幕尺寸和方向调整大小的 UiTextField 框架,但我没有取得太大成功。 (框架如 uitextfieldname.frame(x:,y:,width:,height:) 这是我的代码:

import SpriteKit
import GameplayKit
import UIKit

class GameScene: SKScene {

override func didMove(to view: SKView) {

// Get label node from scene and store it for use later

let animateList = SKAction.sequence([SKAction.fadeIn(withDuration: 1.0), SKAction.wait(forDuration: 2.0), SKAction.fadeOut(withDuration: 1.0)])

let startScreen = SKLabelNode(fontNamed: "Helvetica Neue UltraLight")
startScreen.text = "Welcome"
startScreen.fontSize = 100.0
startScreen.fontColor = SKColor.white
startScreen.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
self.addChild(startScreen)
startScreen.alpha = 0.0



startScreen.run(animateList)

_ = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false) { _ in
startScreen.text = "I don't belive we have met before"

startScreen.run(animateList)

}

_ = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: false) { _ in
startScreen.text = "What's your name?"

startScreen.run(animateList)

}

_ = Timer.scheduledTimer(withTimeInterval: 15.0, repeats: false) { _ in
let name = UITextField()
//name.frame = CGRect(x: ,y: ,width: , height: )
}
}

}

附注

基础上的重要/相关代码

最佳答案

您需要使用自动布局约束固定前导、尾随、顶部和底部约束并设置numberofLines = 0以调整框架。

关于ios - 如何制作一个自动调整的UiTextField Frame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45356074/

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