Skip to content

Commit 6f9098e

Browse files
issue-907: Fixed layout ordering issues
1 parent 8e91d13 commit 6f9098e

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.12.3
2+
3+
* [issue-907](https://github.com/CosmicMind/Material/issues/907): Fixed Layout ordering issues.
4+
15
## 2.12.2
26

37
* [issue-860](https://github.com/CosmicMind/Material/issues/860): Updated TabBar color states and added an independent line color state.

Material.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Material'
3-
s.version = '2.12.2'
3+
s.version = '2.12.3'
44
s.license = 'BSD-3-Clause'
55
s.summary = 'A UI/UX framework for creating beautiful applications.'
66
s.homepage = 'http://materialswift.com'

Sources/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.12.2</string>
18+
<string>2.12.3</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Sources/iOS/Layout.swift

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,26 @@ public class Layout {
631631

632632
fileprivate extension Layout {
633633
/**
634-
Updates and lays out the constraints for a given view.
634+
Updates the consraints for a given view.
635635
- Parameter for view: A UIView.
636636
*/
637637
class func updateConstraints(for view: UIView) {
638-
view.updateConstraintsIfNeeded()
639-
view.updateConstraints()
640-
view.setNeedsLayout()
641-
view.layoutIfNeeded()
638+
DispatchQueue.main.async {
639+
view.setNeedsLayout()
640+
view.layoutIfNeeded()
641+
view.updateConstraintsIfNeeded()
642+
view.updateConstraints()
643+
}
644+
}
645+
646+
/**
647+
Updates the constraints for a given Array of views.
648+
- Parameter for [view]: An Array of UIViews.
649+
*/
650+
class func updateConstraints(for views: [UIView]) {
651+
for v in views {
652+
updateConstraints(for: v)
653+
}
642654
}
643655
}
644656

@@ -700,9 +712,7 @@ extension Layout {
700712
parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right))
701713
}
702714

703-
for child in children {
704-
updateConstraints(for: child)
705-
}
715+
updateConstraints(for: children)
706716
}
707717

708718
/**
@@ -726,9 +736,7 @@ extension Layout {
726736
parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom))
727737
}
728738

729-
for child in children {
730-
updateConstraints(for: child)
731-
}
739+
updateConstraints(for: children)
732740
}
733741

734742
/**

0 commit comments

Comments
 (0)