图一.jpg 图二.jpg开发过程中常常会遇到更新UI布局的情况,如果是纯代码开发,那就得用代码更新相关控件的frame,这个大家一定比较熟悉,所以此处不在赘述;如果是xib写的页面,那该怎样操作呢?下面就来具体说说吧,需求是这样的:初始页面如图一,更新后的页面如图二,点击最近转账人,UI从图一更新到图二。
上代码
//拖的控件
@property (weak, nonatomic) IBOutlet UIView *phoneBG;
@property (weak, nonatomic) IBOutlet UIView *nameBG;
@property (weak, nonatomic) IBOutlet UIView *carNumberBG;
@property (weak, nonatomic) IBOutlet UIView *cardNumberBG;
@property (weak, nonatomic) IBOutlet UIView *codeBG;
@property (weak, nonatomic) IBOutlet UIView *moneyBG;
//拖的约束 控件的高
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *carNumberHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *cardNumberHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *codeHeight;
//点击后更新UI的代码实现
self.codeBG.hidden = YES;
self.codeHeight.constant = 0;
self.cardNumberBG.hidden = YES;
self.cardNumberHeight.constant = 0;
self.carNumberBG.hidden = YES;
self.carNumberHeight.constant = 0;
网友评论