zoukankan      html  css  js  c++  java
  • (八十九)用AutoLayout实现动画和Label根据内容自动调整

    【AutoLayout动画】

    对于storyboard每个约束,都可以像控件那样通过拖线的方式来建立和代码的连接。

    约束是一个对象,通过这个对象的constant属性可以修改约束的点数。

    在修改之后,通过在UIView的animateWithDuration::方法的block内调用[self.view layoutIfNeeded]方法可以实现动画效果,调用layoutIfNeeded时,会调整所有子视图。

    self.redViewtopConstraint.constant += 100;
    [UIView animateWithDuration:0.5 animations:^{
        [self.view layoutIfNeeded]; // 让所有子类约束执行动画
    }];

    【Label自动调整】

    Label的宽高是由内容确定的,因此只需要添加x、y约束即可。

    一旦添加了正确的约束,Label就会自动根据内容调整尺寸了,不必再自己计算,

  • 相关阅读:
    ssh图示+hibernate图示
    spring Transactional
    Spring datasource
    sqlloader导入数据
    Spring Aop Annotation(@Pointcut)
    ajax传输文件+检验
    Spring Aop Annotation
    JDK的动态代理
    nginx代理gitlab
    python相关
  • 原文地址:https://www.cnblogs.com/aiwz/p/6154107.html
Copyright © 2011-2022 走看看