gpt4 book ai didi

sprite-kit - 如何在 tvOS (AppleTV) 上运行的 View Controller 中设置按钮的初始焦点?

转载 作者:行者123 更新时间:2023-12-03 16:32:37 25 4
gpt4 key购买 nike

我在 tvOS 的 Swift 游戏中添加了一些按钮。

override func didMoveToView(view: SKView) {

let button1=UIButton(frame: CGRectMake(330, 800, 300, 100))
button1(imageBuySelected, forState: UIControlState.Focused)
button1(imageBuyNormal, forState: UIControlState.Normal
button1 = UIColor.clearColor()
button1(self, action: "buy1", forControlEvents: UIControlEvents.PrimaryActionTriggered)
self.view!.addSubview(button1)

let button2=UIButton(frame: CGRectMake(330, 800, 300, 100))
button2(imageBuySelected, forState: UIControlState.Focused)
button2(imageBuyNormal, forState: UIControlState.Normal
button2 = UIColor.clearColor()
button2(self, action: "buy2", forControlEvents: UIControlEvents.PrimaryActionTriggered)
self.view!.addSubview(button2)

let button3=UIButton(frame: CGRectMake(330, 800, 300, 100))
button3(imageBuySelected, forState: UIControlState.Focused)
button3(imageBuyNormal, forState: UIControlState.Normal
button3 = UIColor.clearColor()
button3(self, action: "playGame", forControlEvents: UIControlEvents.PrimaryActionTriggered)
self.view!.addSubview(button3)
}

比赛开始时。初始焦点设置为 button1。我希望将焦点设置为 button3。我知道首选焦点是根据从屏幕左上角开始找到的第一个可聚焦对象自动选择的。有谁知道如何覆盖它以便我可以在游戏开始时使 button3 成为首选焦点 View ?

最佳答案

我希望这就是你要找的东西,祝你好运! :)

override var preferredFocusedView: UIView? {
get {
return self.button3
}
}

关于sprite-kit - 如何在 tvOS (AppleTV) 上运行的 View Controller 中设置按钮的初始焦点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32669661/

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