添加约束

iOS AutoLayout的用法

 

iOS AutoLayout的用法

 

iOS AutoLayout的用法

 

代码实现Autolayout的步骤

利用NSLayoutConstraint类创建具体的约束对象

添加约束对象到相应的view上

- (void)addConstraint:(NSLayoutConstraint *)constraint;

- (void)addConstraints:(NSArray *)constraints;

 

代码实现Autolayout的注意点

要先禁止autoresizing功能,设置view的下面属性为NO

view.translatesAutoresizingMaskIntoConstraints = NO;

添加约束之前,一定要保证相关控件都已经在各自的父控件上

不用再给view设置frame

 

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2021-12-19
  • 2021-05-20
  • 2021-05-30
  • 2021-07-04
  • 2021-04-01
猜你喜欢
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案