用Swiftanimation视图高度
我有我的ViewController中查看sView 。 它的高度有约束 – 我为这个约束创build了IBOutlet – sViewHeightConstraint 。 我想用animation降低sView的高度。
我创build了函数
UIView.animateWithDuration(5.5, animations: { self.sViewHeightConstraint.constant = 50 })
视图高度正在改变,但我没有看到任何animation。 我做错了什么?
使用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() })
- 如何阻止应用程序终止用户播放MPMusicPlayerController?
- 用UIButton作为CustomView的UIBarButtonItem – 从UIButton,如何访问UIBarButtonItem它的in?
- UITableView单元格内容不能正确显示
- iOS – 自定义表格单元格不是UITableView的全部宽度
- 子视图中的UIButton在NSLayoutConstraint后没有收到触摸
- 你应用自动布局约束来将标签与背景图像元素alignment?
- 在Xcode 4.5中,在哪里设置转换自动化仓库框架的限制
- iOS自动布局:等同的空间,以适应Superviews宽度
- 当“translatesAutoresizingMaskIntoConstraints”设置为“NO”时,视图消失
- Google地图信息窗口根据内部内容resize
- iOS NSLayoutConstraint使用constraintWithItem固定宽度