Skip to content

Commit 5e72f4b

Browse files
committed
Prevent unwanted animations when adding subviews.
1 parent d0d91b4 commit 5e72f4b

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 1.0.1
5+
6+
### Bug Fixes
7+
* Prevent unwanted animations when adding subviews.
8+
49
## 1.0.0
510

6-
Initial release!
11+
Initial release!

SwiftAutoLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'SwiftAutoLayout'
3-
spec.version = '1.0.0'
3+
spec.version = '1.0.1'
44
spec.license = { :type => 'MIT' }
55
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftAutoLayout'
66
spec.authors = { 'Timothy Moose' => '[email protected]' }

SwiftAutoLayout/RelationalConstraintBuilder.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,24 @@ public class RelationalConstraintBuilder: ConstraintBuilder {
3030
init(first firstConstrainable: Constrainable, second secondConstrainable: Constrainable) {
3131
self.firstConstrainable = firstConstrainable
3232
self.secondConstrainable = secondConstrainable
33-
34-
if let view = firstConstrainable as? UIView {
35-
view.translatesAutoresizingMaskIntoConstraints = false
36-
if view.superview == nil {
33+
34+
UIView.performWithoutAnimation {
35+
if let view = firstConstrainable as? UIView {
36+
view.translatesAutoresizingMaskIntoConstraints = false
37+
if view.superview == nil {
38+
if let otherView = secondConstrainable as? UIView {
39+
otherView.addSubview(view)
40+
} else if let otherLayoutGuide = secondConstrainable as? UILayoutGuide, let otherView = otherLayoutGuide.owningView {
41+
otherView.addSubview(view)
42+
}
43+
}
44+
} else if let layoutGuide = firstConstrainable as? UILayoutGuide, layoutGuide.owningView == nil {
3745
if let otherView = secondConstrainable as? UIView {
38-
otherView.addSubview(view)
39-
} else if let otherLayoutGuide = secondConstrainable as? UILayoutGuide, let otherView = otherLayoutGuide.owningView {
40-
otherView.addSubview(view)
46+
otherView.addLayoutGuide(layoutGuide)
47+
} else if let otherGuide = secondConstrainable as? UILayoutGuide, let otherView = otherGuide.owningView {
48+
otherView.addLayoutGuide(layoutGuide)
4149
}
4250
}
43-
} else if let layoutGuide = firstConstrainable as? UILayoutGuide, layoutGuide.owningView == nil {
44-
if let otherView = secondConstrainable as? UIView {
45-
otherView.addLayoutGuide(layoutGuide)
46-
} else if let otherGuide = secondConstrainable as? UILayoutGuide, let otherView = otherGuide.owningView {
47-
otherView.addLayoutGuide(layoutGuide)
48-
}
4951
}
5052
}
5153
}

0 commit comments

Comments
 (0)