-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathM13ProgressViewRing+GEOAdditions.swift
More file actions
48 lines (40 loc) · 1.58 KB
/
M13ProgressViewRing+GEOAdditions.swift
File metadata and controls
48 lines (40 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// M13ProgressViewRing+GEOAdditions.swift
// RKGeonames
//
// Created by Stefan Buretea on 1/16/17.
// Copyright © 2017 Stefan Burettea. All rights reserved.
//
import Foundation
extension M13ProgressViewRing {
func configure() {
self.indeterminate = true
self.primaryColor = UIColor.white
self.secondaryColor = UIColor.gray
self.backgroundRingWidth = 4.0
self.progressRingWidth = 2.0
}
func animate(in view: UIView, completion: (() -> Void)?) {
guard let superview = self.superview else { return }
for constraint in superview.constraints {
guard constraint.secondItem as? NSObject == self && constraint.firstAttribute == .centerY else { continue }
superview.removeConstraint(constraint)
let newConstraint = NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: superview,
attribute: .top, multiplier: 1, constant: 35)
newConstraint.isActive = true
break
}
UIView.animate( withDuration: 1.0,
delay: 0.0,
usingSpringWithDamping: 1.0,
initialSpringVelocity: 3.0,
options: .curveEaseIn,
animations: {
view.layoutIfNeeded()
},
completion: { (complete: Bool) in
completion?()
}
)
}
}