Skip to content

Commit 2aba800

Browse files
committed
more mild cleanup, but there are limits to how far you can go with this sort of thing
1 parent 8586130 commit 2aba800

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

bk2ch04p130viewAnimation/bk2ch04p130viewAnimation/ViewController.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class ViewController: UIViewController {
5555
print(self.v.center.y)
5656
switch which {
5757
case 1:
58-
UIView.animate(withDuration:0.4, animations: {
58+
UIView.animate(withDuration:0.4) {
5959
self.v.backgroundColor = UIColor.red()
60-
})
60+
}
6161
case 2:
62-
UIView.animate(withDuration:0.4, animations: {
62+
UIView.animate(withDuration:0.4) {
6363
self.v.backgroundColor = UIColor.red()
6464
self.v.center.y += 100
65-
})
65+
}
6666
case 3:
6767
let v2 = UIView()
6868
v2.backgroundColor = UIColor.black()
@@ -81,12 +81,12 @@ class ViewController: UIViewController {
8181
_ in print(self.v.superview)
8282
}
8383
case 5:
84-
UIView.animate(withDuration:1, animations: {
84+
UIView.animate(withDuration:1) {
8585
self.v.backgroundColor = UIColor.red()
8686
UIView.performWithoutAnimation {
8787
self.v.center.y += 100
8888
}
89-
})
89+
}
9090
case 6:
9191
func report(_ ix:Int) {
9292
let pres = (self.v.layer.presentationLayer() as! CALayer).position.y
@@ -129,13 +129,13 @@ class ViewController: UIViewController {
129129
self.v.center.x = xorig
130130
})
131131
case 11:
132-
UIView.animate(withDuration:1, animations: {
132+
UIView.animate(withDuration:1) {
133133
self.v.center.x += 100
134-
})
134+
}
135135
// let opts = UIViewAnimationOptions.beginFromCurrentState
136-
UIView.animate(withDuration:1, animations: {
136+
UIView.animate(withDuration:1) {
137137
self.v.center.y += 100
138-
})
138+
}
139139
case 12:
140140
UIView.animate(withDuration:2, animations: {
141141
self.v.center.x += 100

bk2ch04p132viewAnimationFacade/bk2ch04p132viewAnimationFacade/ViewController.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class ViewController: UIViewController {
88
// MyView presents a facade where its "swing" property is view-animatable
99

1010
@IBAction func doButton(_ sender: AnyObject) {
11-
UIView.animate(withDuration:1, animations: {
11+
UIView.animate(withDuration:1) {
1212
self.v.swing = !self.v.swing // "animatable" Bool property
13-
})
13+
}
1414
}
1515

1616

@@ -23,9 +23,9 @@ class MyView : UIView {
2323
p.x = self.swing ? p.x + 100 : p.x - 100
2424
// this is the trick: perform actual view animation with zero duration
2525
// zero duration means we inherit the surrounding duration
26-
UIView.animate(withDuration:0, animations: {
26+
UIView.animate(withDuration:0) {
2727
self.center = p
28-
})
28+
}
2929
}
3030
}
3131
}

bk2ch04p183animationAndAutolayout/ch17p507animationAndAutolayout/ViewController.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class ViewController : UIViewController {
2222

2323
switch which {
2424
case 1:
25-
UIView.animate(withDuration:1, animations:{
25+
UIView.animate(withDuration:1) {
2626
self.v.center.x += 100
27-
}) // everything *looks* okay, but it isn't
27+
} // everything *looks* okay, but it isn't
2828

2929
case 2:
3030
UIView.animate(withDuration:1, animations:{
@@ -39,9 +39,9 @@ class ViewController : UIViewController {
3939
case 3:
4040
let con = self.v_horizontalPositionConstraint!
4141
con.constant += 100
42-
UIView.animate(withDuration:1, animations:{
42+
UIView.animate(withDuration:1) {
4343
self.v.superview!.layoutIfNeeded()
44-
})
44+
}
4545

4646
case 4:
4747
// this works fine in iOS 8! does not trigger spurious layout
@@ -83,9 +83,9 @@ class ViewController : UIViewController {
8383
snap.frame = self.v.frame
8484
self.v.superview!.addSubview(snap)
8585
self.v.isHidden = true
86-
UIView.animate(withDuration:1, animations:{
86+
UIView.animate(withDuration:1) {
8787
snap.center.x += 100
88-
})
88+
}
8989

9090
case 8:
9191
// don't try this one: it may appear to work but it causes a constraint conflict

bk2ch06p246showHideStatusBar/UnderlappingTest/ViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class ViewController: UIViewController {
1616

1717
@IBAction func doButton(_ sender: AnyObject) {
1818
self.hide = !self.hide
19-
UIView.animate(withDuration:0.4, animations: {
19+
UIView.animate(withDuration:0.4) {
2020
self.setNeedsStatusBarAppearanceUpdate()
2121
self.view.layoutIfNeeded()
22-
})
22+
}
2323
}
2424
}
2525

bk2ch07p384dragInScrollView2/ch20p688dragInScrollView/ViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ class ViewController : UIViewController, UIGestureRecognizerDelegate {
5151
self.flag.frame.origin.x -= self.flag.bounds.size.width
5252
self.flag.isHidden = false
5353

54-
UIView.animate(withDuration:0.25, animations:{
54+
UIView.animate(withDuration:0.25) {
5555
self.flag.frame.origin.x = p.x
5656
// thanks for the flag, now stop operating altogether
5757
g.isEnabled = false
58-
})
58+
}
5959
}
6060

6161
@IBAction func dragging (_ p: UIPanGestureRecognizer) {

bk2ch09p490universalSplitViewControllerManual/SplitViewControllerManual/PrimaryViewController.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ extension PrimaryViewController {
114114
switch svc.displayMode {
115115
case .primaryHidden:
116116
// changing display mode is animatable!
117-
UIView.animate(withDuration:0.2, animations: {
117+
UIView.animate(withDuration:0.2) {
118118
svc.preferredDisplayMode = .primaryOverlay
119-
})
119+
}
120120
default:
121121
svc.preferredDisplayMode = .automatic
122122
}
@@ -132,9 +132,9 @@ extension PrimaryViewController {
132132
self.verticalConstraints =
133133
NSLayoutConstraint.constraints(withVisualFormat:"V:|-(minuscon)-[v]-(con)-|", metrics: ["con":con, "minuscon":-con], views: ["v":vc2.view])
134134
NSLayoutConstraint.activate(self.verticalConstraints!)
135-
UIView.animate(withDuration:0.25, animations: {
135+
UIView.animate(withDuration:0.25) {
136136
self.view.layoutIfNeeded()
137-
})
137+
}
138138
}
139139
}
140140
}

bk2ch12p589segmentedControl/ch25p862segmentedControl/ViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class ViewController: UIViewController {
5252

5353
self.seg.layer.speed = 0.2
5454
delay(1) {
55-
UIView.animate(withDuration:0.4, animations: {
55+
UIView.animate(withDuration:0.4) {
5656
self.seg.selectedSegmentIndex = 1
57-
})
57+
}
5858
}
5959

6060
// self.seg.tintColor = UIColor.red()

0 commit comments

Comments
 (0)