Skip to content

Commit

Permalink
Prevent unwanted animations when adding subviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtmoose committed Dec 15, 2018
1 parent d0d91b4 commit 5e72f4b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## 1.0.1

### Bug Fixes
* Prevent unwanted animations when adding subviews.

## 1.0.0

Initial release!
Initial release!
2 changes: 1 addition & 1 deletion SwiftAutoLayout.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'SwiftAutoLayout'
spec.version = '1.0.0'
spec.version = '1.0.1'
spec.license = { :type => 'MIT' }
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftAutoLayout'
spec.authors = { 'Timothy Moose' => '[email protected]' }
Expand Down
28 changes: 15 additions & 13 deletions SwiftAutoLayout/RelationalConstraintBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ public class RelationalConstraintBuilder: ConstraintBuilder {
init(first firstConstrainable: Constrainable, second secondConstrainable: Constrainable) {
self.firstConstrainable = firstConstrainable
self.secondConstrainable = secondConstrainable

if let view = firstConstrainable as? UIView {
view.translatesAutoresizingMaskIntoConstraints = false
if view.superview == nil {

UIView.performWithoutAnimation {
if let view = firstConstrainable as? UIView {
view.translatesAutoresizingMaskIntoConstraints = false
if view.superview == nil {
if let otherView = secondConstrainable as? UIView {
otherView.addSubview(view)
} else if let otherLayoutGuide = secondConstrainable as? UILayoutGuide, let otherView = otherLayoutGuide.owningView {
otherView.addSubview(view)
}
}
} else if let layoutGuide = firstConstrainable as? UILayoutGuide, layoutGuide.owningView == nil {
if let otherView = secondConstrainable as? UIView {
otherView.addSubview(view)
} else if let otherLayoutGuide = secondConstrainable as? UILayoutGuide, let otherView = otherLayoutGuide.owningView {
otherView.addSubview(view)
otherView.addLayoutGuide(layoutGuide)
} else if let otherGuide = secondConstrainable as? UILayoutGuide, let otherView = otherGuide.owningView {
otherView.addLayoutGuide(layoutGuide)
}
}
} else if let layoutGuide = firstConstrainable as? UILayoutGuide, layoutGuide.owningView == nil {
if let otherView = secondConstrainable as? UIView {
otherView.addLayoutGuide(layoutGuide)
} else if let otherGuide = secondConstrainable as? UILayoutGuide, let otherView = otherGuide.owningView {
otherView.addLayoutGuide(layoutGuide)
}
}
}
}
Expand Down

0 comments on commit 5e72f4b

Please sign in to comment.