我有一个UIButton放置与约束.在视图控制器的界面中,我为该按钮的高度约束创建了一个IBOutlet.在viewDidLoad方法中我有代码:
myButtonConstraint.constat = 0; [self.view layoutIfNeeded];
在viewWillAppear中,按钮的高度为0,但在模拟器上,按钮的标题仍然可见.即使按钮的标题是可见的,该按钮是不可插拔的,它不执行任何操作.
到底是怎么回事?
解决方法
您可以在界面构建器上检查剪辑子视图,或者如果要通过代码尝试此操作:
myButtonConstraint.clipsToBounds = YES
从苹果文档:
clipsToBounds
A Boolean value that determines whether subviews are confined to the bounds of the view.
@property(nonatomic) BOOL clipsToBounds
Discussion
Setting this value to YES causes subviews to be clipped to the bounds of the receiver. If set to NO,subviews whose frames extend beyond the visible bounds of the receiver are not clipped. The default value is NO.