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

      3. <small id='ZC5Mt'></small><noframes id='ZC5Mt'>

      4. 突出显示 UIControl 子类

        时间:2023-07-07
      5. <i id='K4v3d'><tr id='K4v3d'><dt id='K4v3d'><q id='K4v3d'><span id='K4v3d'><b id='K4v3d'><form id='K4v3d'><ins id='K4v3d'></ins><ul id='K4v3d'></ul><sub id='K4v3d'></sub></form><legend id='K4v3d'></legend><bdo id='K4v3d'><pre id='K4v3d'><center id='K4v3d'></center></pre></bdo></b><th id='K4v3d'></th></span></q></dt></tr></i><div id='K4v3d'><tfoot id='K4v3d'></tfoot><dl id='K4v3d'><fieldset id='K4v3d'></fieldset></dl></div>
        • <bdo id='K4v3d'></bdo><ul id='K4v3d'></ul>

                <tbody id='K4v3d'></tbody>

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

                • <tfoot id='K4v3d'></tfoot>
                • <legend id='K4v3d'><style id='K4v3d'><dir id='K4v3d'><q id='K4v3d'></q></dir></style></legend>
                  本文介绍了突出显示 UIControl 子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述


                  基本上我需要一个图像按钮,特别是一个自定义对象:
                  1) 点击时调用控制器的动作
                  2) 封装自定义数据
                  3) 由包装视图自动移动(不相关)


                  basically I need an image button, specifically a custom object that:
                  1) calls a controller's action when tapped
                  2) encapsulates custom data
                  3) is automatically moved by wrapper view (not relevant)

                  好吧,我通过 UIControl 的子类得到了所有这些(因为不推荐子类化 UIButton 并且子类化 UIImageView 使得管理第 1 点).但是现在突出显示它的正确方法是什么?我想在以任何方式点击时突出显示控件(即使是简单的 alpha 瞬间减少).

                  Well, I got all this with a subclass of UIControl (since subclassing UIButton is not recommended and subclassing UIImageView makes difficult to manage the point 1). But now what is the correct way to highlight it? I would like to highlight the control when tapped in any way (even a simple momentary reduction of alpha).

                  使用 beginTrackingWithTouchendTrackingWithTouch 我无法识别唯一的 UIControlEventTouchUpInside 事件.

                  With beginTrackingWithTouch and endTrackingWithTouch I can't recognize the only UIControlEventTouchUpInside event.

                  控制器中的视图动画?在我看来这是一个粗略的解决方案

                  A view animation in the controller? It seems to me a rough solution

                  有没有简单直接的解决方案?

                  Is there a simple and immediate solution?

                  谢谢:(

                  推荐答案

                  我认为 UIControls 会自动正确设置其突出显示的属性,仅基于触摸事件.您需要重写 -setHighlighted: 方法来实现特定算法:

                  I think UIControls automatically set their highlighted property correctly, based solely on touch events. What you need is to override -setHighlighted: method to implement a specific algorithm:

                  - (void) setHighlighted: (BOOL) highlighted {
                      [super setHighlighted: highlighted];
                      // Only as an example. Caution: looks like a disabled control
                      self.alpha = highlighted ? 0.5f : 1.0f;
                  }
                  

                  这篇关于突出显示 UIControl 子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Swift 中为状态设置属性标题颜色 下一篇:自定义按钮框架看起来不如圆形矩形 UIButton

                  相关文章

                    <bdo id='k6r2q'></bdo><ul id='k6r2q'></ul>
                  1. <legend id='k6r2q'><style id='k6r2q'><dir id='k6r2q'><q id='k6r2q'></q></dir></style></legend>
                  2. <small id='k6r2q'></small><noframes id='k6r2q'>

                      <tfoot id='k6r2q'></tfoot>

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