简体   繁体   中英

View doesn't appear after changing the view property 'isHidden = false'

I'm developing an iOS application and then the issue that I have faced now is showing a view using the view property isHidden .

I initialized a custom view including a CAAnimation and then set the default isHidden property true to hide. After a certain condition meets I changed the isHidden property to false to show it. But in this case the view doesn't appear.

    private func setupButtonEffectView() {
      self.buttonEffectView = ButtonEffectView()
      self.buttonEffectView!.translatesAutoresizingMaskIntoConstraints = false
//      self.view.addSubview(self.buttonEffectView!)
      self.view.insertSubview(self.buttonEffectView!, belowSubview: self.button!)

      NSLayoutConstraint.activate([
        self.buttonEffectView!.centerXAnchor.constraint(equalTo: self.button!.centerXAnchor),
        self.buttonEffectView!.centerYAnchor.constraint(equalTo: self.button!.centerYAnchor),
        self.buttonEffectView!.widthAnchor.constraint(equalToConstant: 100),
        self.buttonEffectView!.heightAnchor.constraint(equalToConstant: 100)
        ])

      self.buttonEffectView!.isHidden = true
    }

I created the button effect using the method above.

Try instead of hiding the view, setting the alpha to 0.0. self.buttonEffectView.alpha = 0.0 . Then when you want to show it set the alpha to 1.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM