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

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

      1. <tfoot id='SAU0X'></tfoot>
        <legend id='SAU0X'><style id='SAU0X'><dir id='SAU0X'><q id='SAU0X'></q></dir></style></legend>

        动画按钮 Allowuserinteraction 不起作用

        时间:2023-07-06
        <legend id='voFdr'><style id='voFdr'><dir id='voFdr'><q id='voFdr'></q></dir></style></legend>
          <bdo id='voFdr'></bdo><ul id='voFdr'></ul>

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

                <tbody id='voFdr'></tbody>
                <tfoot id='voFdr'></tfoot>
                • 本文介绍了动画按钮 Allowuserinteraction 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 NSObject 类的代码中创建了一个 UIbutton,它控制 UIViewController 类中的游戏.该按钮在整个游戏的大部分时间都可以正常工作,但在某些时候我希望该按钮淡入/淡出.一旦淡入/淡出开始动画,按钮就不再是交互式的.我已经设置了 .AllowUserInteraction 选项,但仍然没有运气.我被这个难住了,所以非常感谢任何帮助!

                  I have a UIbutton created in code in an NSObject class which controls a game in a UIViewController class. The button works fine throughout most of the game, but at a certain point I want the button to fadein/out. Once the fadein/out starts animating the button is no longer interactive. I have set the .AllowUserInteraction option, but still no luck. I am stumped on this one, so any help much appreciated!

                  Class GameController: NSObject {
                  var gameView: UIView!
                  var nextButton: UIButton!
                  
                  func gameViewSetUp() {
                      // create the nextButton
                      let imageNextButton = UIImage(named: "rightArrow") as UIImage?
                      self.nextButton = UIButton(type: .Custom)
                      nextButton.frame = CGRectMake(ScreenWidth-100,ScreenHeight-250,60,60)
                      nextButton.setTitle("", forState: UIControlState.Normal)
                      nextButton.setImage(imageNextButton, forState: .Normal)
                      nextButton.contentMode = .ScaleAspectFill
                      nextButton.backgroundColor = UIColor.clearColor()
                      nextButton.layer.cornerRadius = 5.0
                      nextButton.layer.borderWidth = 2.5
                      nextButton.layer.borderColor = UIColor.clearColor().CGColor
                      nextButton.addTarget(self, action: "nextPressed", forControlEvents: .TouchUpInside)
                      nextButton.userInteractionEnabled = true
                      gameView.addSubview(nextButton)
                  
                  func playStageX() { 
                         nextButtonWink()
                      }
                  }
                  
                  func nextButtonWink() {
                      UIView.animateWithDuration(1.5, delay: 0, options: [.AllowUserInteraction, .Repeat, .CurveEaseInOut, .Autoreverse],
                          animations: {
                   // self.nextButton.userInteractionEnabled = true // I tried this as well but no impact.
                              self.nextButton.alpha = 0
                          }, completion: nil)
                  }
                  
                  class GameViewController: UIViewController {
                  private var controller: GameController
                  required init?(coder aDecoder: NSCoder) {
                      controller = GameController()
                      super.init(coder: aDecoder)
                  }
                  override func viewDidLoad() {
                      super.viewDidLoad()   
                      let gameView = UIView(frame: CGRectMake(0, 0, ScreenWidth, ScreenHeight))
                      self.view.addSubview(gameView)
                      controller.gameView = gameView
                  

                  }

                  推荐答案

                  拿出self.nextButton.alpha = 0来测试一下,相信alpha为零时按钮事件不会触发.当涉及到动画时,实际对象的 alpha 将在动画开始之前设置为零,您所看到的就像动画时视图的渲染交互式屏幕截图

                  Take out self.nextButton.alpha = 0 to test this out, I believe that button events will not fire when alpha is zero. When it comes to animations, the actual object's alpha will get set to zero before the animation starts, and what you are seeing is like a rendered interactive screenshot of your view as it animates

                  如果是这种情况,那么您需要将 alpha 设置为 0.0100000003 或覆盖按钮以在 alpha 0 处进行交互

                  If that is the case, then you need to set the alpha to something like 0.0100000003 or override the button to be interactive at alpha 0

                  这篇关于动画按钮 Allowuserinteraction 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iPhone:覆盖 UIButton buttonWithType 以返回子类 下一篇:UIButton 改变位置

                  相关文章

                    <bdo id='bwiAX'></bdo><ul id='bwiAX'></ul>
                    <tfoot id='bwiAX'></tfoot>

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

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