2017-07-31 74 views
0

我试图从swift Xcode项目中的viewController中删除一个UIImageView,如果某种条件存在(如果用户购买了“删除广告”)。我能够通过将图像'.image设置为nil以及将其大小设置为nil的约束条件来实现。但是,当我这样做时,按钮将转到视图底部的正确位置,但按钮的可按区域不再是整个按钮。如果我触摸它的左下角,我可以按它。是否有多个图层限制Xcode中的按钮?

如果我能够在适当的位置呈现按钮的外观,我该如何影响功能区域呢?

+0

能否请你告诉你的代码? – dfd

+0

@dfd什么代码对你最有用?约束是使用故事板构建的,因此我没有发布它们。 – matador0227

+0

图片前后上传可以帮助人们理解你的问题。 – Puttin

回答

0

这是我使用的代码,而不是图像和横幅视图的nil

 self.adBannerView.removeFromSuperview() 
     self.bottomGreyArea.removeFromSuperview() 

     self.view.addConstraint(NSLayoutConstraint(item: nextButton, attribute: .bottom, relatedBy: .equal, toItem: self.bottomLayoutGuide, attribute:.top, multiplier: 1, constant: 0)) 
     self.view.addConstraint(NSLayoutConstraint(item: backButton, attribute: .bottom, relatedBy: .equal, toItem: self.bottomLayoutGuide, attribute:.top, multiplier: 1, constant: 0)) 
     self.nextButton.translatesAutoresizingMaskIntoConstraints = false 
     self.backButton.translatesAutoresizingMaskIntoConstraints = false 

从上海华盈删除清除了所有的约束,所以后来我重建的按钮相关的约束(这在以前依赖于bottomGreyArea。一切都很好,在世界上了!

0

您应该检查按钮新的frame或按钮前面的任何视图,以捕捉触摸事件。

通常情况下,UIButton触摸区域是其框架区域。

相关问题