• <bdo id='lAGwh'></bdo><ul id='lAGwh'></ul>
    <i id='lAGwh'><tr id='lAGwh'><dt id='lAGwh'><q id='lAGwh'><span id='lAGwh'><b id='lAGwh'><form id='lAGwh'><ins id='lAGwh'></ins><ul id='lAGwh'></ul><sub id='lAGwh'></sub></form><legend id='lAGwh'></legend><bdo id='lAGwh'><pre id='lAGwh'><center id='lAGwh'></center></pre></bdo></b><th id='lAGwh'></th></span></q></dt></tr></i><div id='lAGwh'><tfoot id='lAGwh'></tfoot><dl id='lAGwh'><fieldset id='lAGwh'></fieldset></dl></div>
  • <small id='lAGwh'></small><noframes id='lAGwh'>

    <legend id='lAGwh'><style id='lAGwh'><dir id='lAGwh'><q id='lAGwh'></q></dir></style></legend>
    <tfoot id='lAGwh'></tfoot>

      1. 使用 Swift 动画视图高度

        Animate view height with Swift(使用 Swift 动画视图高度)
        <legend id='9YSF4'><style id='9YSF4'><dir id='9YSF4'><q id='9YSF4'></q></dir></style></legend>
        <i id='9YSF4'><tr id='9YSF4'><dt id='9YSF4'><q id='9YSF4'><span id='9YSF4'><b id='9YSF4'><form id='9YSF4'><ins id='9YSF4'></ins><ul id='9YSF4'></ul><sub id='9YSF4'></sub></form><legend id='9YSF4'></legend><bdo id='9YSF4'><pre id='9YSF4'><center id='9YSF4'></center></pre></bdo></b><th id='9YSF4'></th></span></q></dt></tr></i><div id='9YSF4'><tfoot id='9YSF4'></tfoot><dl id='9YSF4'><fieldset id='9YSF4'></fieldset></dl></div>

            <bdo id='9YSF4'></bdo><ul id='9YSF4'></ul>
                  <tbody id='9YSF4'></tbody>
                  <tfoot id='9YSF4'></tfoot>

                  <small id='9YSF4'></small><noframes id='9YSF4'>

                  本文介绍了使用 Swift 动画视图高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 ViewController 中有视图 sView.它的高度有约束 - 我为这个约束创建了 IBOutlet - sViewHeightConstraint.我想用动画降低 sView 的高度.

                  I have view sView inside my ViewController. It height has constraint - I created IBOutlet for this constraint - sViewHeightConstraint. I want to decrease height of sView with animation.

                  我创建了函数

                  UIView.animateWithDuration(5.5, animations: {
                                  self.sViewHeightConstraint.constant = 50
                              })
                  

                  视图高度正在改变,但我没有看到任何动画.我做错了什么?

                  Height of view is changing but i don't see any animation. What I am doing wrong?

                  推荐答案

                  使用 layoutIfNeeded()

                   view.layoutIfNeeded() // force any pending operations to finish
                  
                   UIView.animateWithDuration(0.2, animations: { () -> Void in
                      self.sViewHeightConstraint.constant = 50
                      self.view.layoutIfNeeded()
                  })
                  

                  斯威夫特 3

                  view.layoutIfNeeded() 
                  sViewHeightConstraint.constant = 50
                  
                  UIView.animate(withDuration: 1.0, animations: { 
                       self.view.layoutIfNeeded() 
                  })
                  

                  这篇关于使用 Swift 动画视图高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员

                    • <small id='6vkua'></small><noframes id='6vkua'>

                        <tbody id='6vkua'></tbody>
                      <legend id='6vkua'><style id='6vkua'><dir id='6vkua'><q id='6vkua'></q></dir></style></legend>
                    • <tfoot id='6vkua'></tfoot>

                        <i id='6vkua'><tr id='6vkua'><dt id='6vkua'><q id='6vkua'><span id='6vkua'><b id='6vkua'><form id='6vkua'><ins id='6vkua'></ins><ul id='6vkua'></ul><sub id='6vkua'></sub></form><legend id='6vkua'></legend><bdo id='6vkua'><pre id='6vkua'><center id='6vkua'></center></pre></bdo></b><th id='6vkua'></th></span></q></dt></tr></i><div id='6vkua'><tfoot id='6vkua'></tfoot><dl id='6vkua'><fieldset id='6vkua'></fieldset></dl></div>

                          • <bdo id='6vkua'></bdo><ul id='6vkua'></ul>