platform :ios, '13.0'
use_frameworks!
target 'DemoApp' do
source 'https://github.com/CocoaPods/Specs.git'
pod 'Spring', :git => 'https://github.com/MengTo/Spring.git'
end
import UIKit
import Spring //第三方;
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let image = UIImage(named:"star")
let imageView = SpringImageView(image: image) // Spring的ImageView;
imageView.frame = CGRect(x: 0, y: 0, width: 160, height: 160)
imageView.center = self.view.center
self.view.addSubview(imageView)
imageView.animation = "squeezeDown"
imageView.autostart = true
}
}
-
- 自定义回弹
import UIKit
import Spring
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
yeTye()
}
func yeTye(){ // 自定义回调
let image = UIImage(named:"star")
let imageView = SpringImageView(image: image) // 实例化回调UI;
imageView.frame = CGRect(x: 0, y: 0, width: 80, height: 80)
imageView.center = CGPoint(x: 207, y: 300)
self.view.addSubview(imageView)
imageView.animation = "squeezeDown"
imageView.autostart = true
imageView.force = 0.5
imageView.curve = "spring"
imageView.duration = 1.0
imageView.animateToNext {
imageView.force = 5.0
imageView.duration = 2.0
imageView.delay = 2.0
imageView.repeatCount = 2
imageView.curve = "easeIn"
imageView.animation = "shake"
imageView.animateTo()
}
}
}