UIView addSubview auto layout not working

前端 未结 3 625
Happy的楠姐
Happy的楠姐 2021-01-19 23:46

I created a UIView programatically and add NSLayoutConstraint to it and it works and then add it as a subView of view controller\'s view. Right now I need to remove this vie

3条回答
  •  一向
    一向 (楼主)
    2021-01-20 00:00

    When you create constraints assign it to variables

    @property (nonatomic, strong)NSLayoutConstraint *viewConstraintTop;
    self.viewConstraintTop = [Your Constraint];
    

    When you want to remove it from the superview remove the constraints

    [self.viewConstraintTop autoRemove];
    

    Remove your view and again while adding assign the constraint as

    self.viewConstraintTop = [Your Constraint];
    

提交回复
热议问题