简体   繁体   English

如何在 swift 中创建弹跳效果?

[英]How to create bouncing effect in swift?

I have created a popup in swift using UIView and I want to bounce it when displaying, but I don't know how to do that.我已经使用 UIView 在 swift 中创建了一个弹出窗口,我想在显示时反弹它,但我不知道该怎么做。 I want to make the same effect as seen below:我想制作如下所示的相同效果:

在此处输入图像描述

You should use UIView.animate with usingSpringWithDamping and initialSpringVelocity parameters.您应该使用 UIView.animate 与 usingSpringWithDamping 和 initialSpringVelocity 参数。 Eg:例如:

// Change position of view
UIView.animate(withDuration: 1.0, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.0, options: [], animations: {
    // Call layoutIfNeeded()
})

Or you can change view's position in animation completion block.或者您可以在 animation 完成块中更改视图的 position。 But it's not recommended.但不建议这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在WKWebView中禁用弹跳效果 - How to disable bouncing effect in WKWebView 如何使用 CAKeyframeAnimation 用于弹跳效果 IOS - how to use CAKeyframeAnimation is for Bouncing effect IOS Swift / SpriteKit:如何创建水滴效果? - Swift / SpriteKit: How to create a water drop effect? 如何在Swift中创建指向UIImages的闪烁指针效果 - How to create a flashing pointer effect to UIImages in Swift 如何在不影响刷新控件功能的情况下禁用collectionview弹跳效果? - How to disable collectionview bouncing effect without affecting refresh control functionality? 我没有在Swift中创建的东西的SKSpriteNode弹跳 - SKSpriteNode bouncing of something I didn't create in Swift 如何在 ios 上的 Xamarin.Forms CollectionView 中关闭弹跳效果 - How to turn off bouncing effect in Xamarin.Forms CollectionView on ios Swift如何在UIViewController和UITableViewController之间创建类似于UIPageViewController的效果 - Swift how to create an effect similar to it of UIPageViewController between a UIViewController and UITableViewController iOS 如何在滚动视图中为图像 Swift 创建视差效果 - iOS How to create parallax effect in scroll view for image Swift 禁用离子3中的ios弹跳效果 - disable bouncing effect of ios in ionic 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM