<legend id='CEyOm'><style id='CEyOm'><dir id='CEyOm'><q id='CEyOm'></q></dir></style></legend>

      <small id='CEyOm'></small><noframes id='CEyOm'>

    1. <i id='CEyOm'><tr id='CEyOm'><dt id='CEyOm'><q id='CEyOm'><span id='CEyOm'><b id='CEyOm'><form id='CEyOm'><ins id='CEyOm'></ins><ul id='CEyOm'></ul><sub id='CEyOm'></sub></form><legend id='CEyOm'></legend><bdo id='CEyOm'><pre id='CEyOm'><center id='CEyOm'></center></pre></bdo></b><th id='CEyOm'></th></span></q></dt></tr></i><div id='CEyOm'><tfoot id='CEyOm'></tfoot><dl id='CEyOm'><fieldset id='CEyOm'></fieldset></dl></div>
    2. <tfoot id='CEyOm'></tfoot>
      • <bdo id='CEyOm'></bdo><ul id='CEyOm'></ul>

    3. 在 Swift (tvOS) 中,如何更改 UIButton 的突出显示和焦点颜色?

      In Swift (tvOS) how do you change a UIButton#39;s highlight and focus colors?(在 Swift (tvOS) 中,如何更改 UIButton 的突出显示和焦点颜色?)
        <tbody id='eaWcO'></tbody>
      <legend id='eaWcO'><style id='eaWcO'><dir id='eaWcO'><q id='eaWcO'></q></dir></style></legend>

      <i id='eaWcO'><tr id='eaWcO'><dt id='eaWcO'><q id='eaWcO'><span id='eaWcO'><b id='eaWcO'><form id='eaWcO'><ins id='eaWcO'></ins><ul id='eaWcO'></ul><sub id='eaWcO'></sub></form><legend id='eaWcO'></legend><bdo id='eaWcO'><pre id='eaWcO'><center id='eaWcO'></center></pre></bdo></b><th id='eaWcO'></th></span></q></dt></tr></i><div id='eaWcO'><tfoot id='eaWcO'></tfoot><dl id='eaWcO'><fieldset id='eaWcO'></fieldset></dl></div>
        <bdo id='eaWcO'></bdo><ul id='eaWcO'></ul>
              • <tfoot id='eaWcO'></tfoot>

                <small id='eaWcO'></small><noframes id='eaWcO'>

                本文介绍了在 Swift (tvOS) 中,如何更改 UIButton 的突出显示和焦点颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                因此,我通过 Interface Builder 添加了一些按钮,而不是使用自定义的系统按钮.我试图弄清楚如何更改特征,例如在不同状态(突出显示、聚焦等)期间的文本颜色和背景颜色.

                So I have some buttons that I've added to a view through the Interface Builder and rather than using the system buttons I made them custom. I'm trying to figure out how to change characteristics, such as the text color and background color during different states (highlighted, focused, etc).

                我似乎无法通过 IB 来实现,所以我可能会创建 UIButton 的子类并在那里更改它们,但我无法找到要更改的属性.我没有看到文档中明确提到它们

                It doesn't seem like I can do it through the IB so I'll probably make a subclass of UIButton and change them there, but I'm having trouble finding what properties to change. I don't see them explicitly mentioned in the documentation

                推荐答案

                你绝对是在正确的轨道上!

                You're definitely on the right track!

                一旦你继承了 UIButton,你就可以重写函数 didUpdateFocusInContext(来自 UIFocusEnvironment 协议,tvOS 上的 UIButton 已经实现了)

                Once you subclass UIButton, you can override the function didUpdateFocusInContext (from UIFocusEnvironment protocol, which UIButton on tvOS already implements)

                override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
                    super.didUpdateFocusInContext(context, withAnimationCoordinator: coordinator)
                
                    if context.nextFocusedView == self {
                        // This is when the button will be focused
                        // You can change the backgroundColor and textColor here
                    } else {
                        // This is when the focus has left and goes back to default
                        // Don't forget to reset the values
                    }
                }
                

                您还可以花哨并变换框架以模仿默认的焦点"效果!

                You can also get fancy and transform the frame to imitate the default "focus" effect!

                这篇关于在 Swift (tvOS) 中,如何更改 UIButton 的突出显示和焦点颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                UIButton title text color(UIButton 标题文本颜色)
                Stretch background image for UIButton(为 UIButton 拉伸背景图像)
                Using Tint color on UIImageView(在 UIImageView 上使用 Tint 颜色)
                How can I change UIButton title color?(如何更改 UIButton 标题颜色?)
                iPhone UIButton - image position(iPhone UIButton - 图像位置)
                UIButton remove all target-actions(UIButton 删除所有目标动作)
              • <small id='RVn6C'></small><noframes id='RVn6C'>

                  <tbody id='RVn6C'></tbody>
                  <i id='RVn6C'><tr id='RVn6C'><dt id='RVn6C'><q id='RVn6C'><span id='RVn6C'><b id='RVn6C'><form id='RVn6C'><ins id='RVn6C'></ins><ul id='RVn6C'></ul><sub id='RVn6C'></sub></form><legend id='RVn6C'></legend><bdo id='RVn6C'><pre id='RVn6C'><center id='RVn6C'></center></pre></bdo></b><th id='RVn6C'></th></span></q></dt></tr></i><div id='RVn6C'><tfoot id='RVn6C'></tfoot><dl id='RVn6C'><fieldset id='RVn6C'></fieldset></dl></div>

                    • <tfoot id='RVn6C'></tfoot><legend id='RVn6C'><style id='RVn6C'><dir id='RVn6C'><q id='RVn6C'></q></dir></style></legend>
                        <bdo id='RVn6C'></bdo><ul id='RVn6C'></ul>