1.實現(xiàn)過程:在VCviewDidload方法中self.viewaddSubView:aLabel,viewWillLayoutSubviews中使用Masonry添加label約束;另外界面有一個button,當(dāng)當(dāng)點擊button時候做動畫.-(void)viewDidLoad{[superviewDidLoad];[self.viewaddSubview:self.nameLabel];}-(UILabel*)nameLabel{if(!_nameLabel){_nameLabel=[[UILabelalloc]initWithFrame:CGRectZero];_nameLabel.lineBreakMode=NSLineBreakByTruncatingTail;_nameLabel.text=@"王二小";_nameLabel.backgroundColor=[UIColorgreenColor];_nameLabel.textAlignment=NSTextAlignmentLeft;}return_nameLabel;}-(void)viewWillLayoutSubviews{[selfaddCContraints];}-(void)addCContraints{[self.nameLabelmas_makeConstraints:^(MASConstraintMaker*make){make.left.equalTo(self.view.mas_left).offset(10);make.top.equalTo(self.view.mas_top).offset(10);}];}//點擊button的響應(yīng)時間.-(void)animationAction{///設(shè)置長度.[self.nameLabelmas_updateConstraints:^(MASConstraintMaker*make){make.left.mas_equalTo(-30);}];[UIViewanimateWithDuration:0.3animations:^{[self.nameLabel.superviewlayoutIfNeeded];}];}**"約束沖突信息:"**2017-08-0922:24:47.196344NSString[13501:3837010][LayoutConstraints]Unabletosimultaneouslysatisfyconstraints.Probablyatleastoneoftheconstraintsinthefollowinglistisoneyoudon'twant.Trythis:(1)lookateachconstraintandtrytofigureoutwhichyoudon'texpect;(2)findthecodethataddedtheunwantedconstraintorconstraintsandfixit.("","")WillattempttorecoverbybreakingconstraintMakeasymbolicbreakpointatUIViewAlertForUnsatisfiableConstraintstocatchthisinthedebugger.ThemethodsintheUIConstraintBasedLayoutDebuggingcategoryonUIViewlistedinmayalsobehelpful.跟了下Masonry執(zhí)行過程也沒發(fā)現(xiàn)什么問題.有朋友遇到過這種問題么?感謝在先.
iOS 使用Masonry庫做動畫時報錯?
牧羊人nacy
2019-05-24 19:01:21