Giter VIP home page Giter VIP logo

Comments (7)

youngsoft avatar youngsoft commented on June 4, 2024

您可以在设置完子视图的tg_xxxx属性后,或者设置完布局视图的tg_xxxx属性后,然后调用方法tg_layoutAnimationWithDuration来执行动画比如:

 let layout = TGLinearLayout(.vert)
  
  let sbv = UIView()
  sbv.tg_width.equal(.fill)
  sbv.tg_height.equal(100)
  layout.addSubview(sbv)
  
。。。。。。。
 //假设这里在其他地方需要改变sbv的高度而产生动画。
 sbv.tg_height.equal(200)
layout.tg_layoutAnimationWithDuration(0.3)  //调用后将会产生尺寸变化的动画。

//你也可以用如下代码来实现动画效果:

sbv.tg_height.equal(200)

 UIView.animate(withDuration: 0.3) {
            
        layout.layoutIfNeeded() 
}

具体您可以搜索我的DEMO里面的关键字tg_layoutAnimationWithDuration或UIView.animate来更加详细的了解TangramKit对动画的支持。

from tangramkit.

MagicalWater avatar MagicalWater commented on June 4, 2024

好的, 非常感謝, 我去試試看

from tangramkit.

BadReese avatar BadReese commented on June 4, 2024

但是这样执行动画的时候
如果sbv上方有其他VIEW
这个VIEW会马上出现在被顶起后的位置
只有sbv会因为动画慢慢变高
怎么办呢

from tangramkit.

youngsoft avatar youngsoft commented on June 4, 2024

但是这样执行动画的时候
如果sbv上方有其他VIEW
这个VIEW会马上出现在被顶起后的位置
只有sbv会因为动画慢慢变高
怎么办呢


那就为父布局设置动画,或者再往上一级设置动画

from tangramkit.

BadReese avatar BadReese commented on June 4, 2024

但是这样执行动画的时候
如果sbv上方有其他VIEW
这个VIEW会马上出现在被顶起后的位置
只有sbv会因为动画慢慢变高
怎么办呢

那就为父布局设置动画,或者再往上一级设置动画

谢谢欧阳大哥,确实我最终是为layout的上一级做动画的
但我不太懂这原理,可以请您帮我解释下么?谢谢

from tangramkit.

youngsoft avatar youngsoft commented on June 4, 2024

如果有可能其实你看一下源代码就好,因为那个动画函数其实是在布局视图执行layoutSubviews方法内部执行的,而layoutSubviews又调整了所有子视图的frame值。就相当于如下形式:

布局视图的 layoutSubviews实现

开始动画函数
调整所有子视图的frame值
结束动画函数



from tangramkit.

BadReese avatar BadReese commented on June 4, 2024

恩呀
谢谢你
我去看看

from tangramkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.