Skip to content

Commit 2639ea8

Browse files
committed
Fixed an issue where setting hidden value without animation would not show the arrangedSubview(s)
1 parent 56c8be3 commit 2639ea8

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

Example/TZStackView-Example/TZStackView/TZStackView.swift

100644100755
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,30 @@ class TZStackView: UIView {
119119
animationDidStopQueueEntries.insert(TZAnimationDidStopQueueEntry(view: view, hidden: hidden), atIndex: 0)
120120
UIView.setAnimationDidStopSelector("hiddenAnimationStopped")
121121
} else {
122-
view.hidden = hidden
123-
addHiddenListener(view)
122+
didFinishSettingHiddenValue(view, hidden: hidden)
124123
}
125124
}
126125
}
127126

127+
private func didFinishSettingHiddenValue(arrangedSubview: UIView, hidden: Bool) {
128+
arrangedSubview.hidden = hidden
129+
if let index = find(animatingToHiddenViews, arrangedSubview) {
130+
animatingToHiddenViews.removeAtIndex(index)
131+
}
132+
addHiddenListener(arrangedSubview)
133+
}
134+
128135
func hiddenAnimationStopped() {
129136
var queueEntriesToRemove = [TZAnimationDidStopQueueEntry]()
130137
for entry in animationDidStopQueueEntries {
131138
let view = entry.view
132139
if view.layer.animationKeys() == nil {
133-
view.hidden = entry.hidden
134-
135-
if let index = find(animatingToHiddenViews, view) {
136-
animatingToHiddenViews.removeAtIndex(index)
137-
}
138-
addHiddenListener(view)
140+
didFinishSettingHiddenValue(view, hidden: entry.hidden)
139141
queueEntriesToRemove.append(entry)
140142
}
141143
}
142144
for entry in queueEntriesToRemove {
143-
let index = find(animationDidStopQueueEntries, entry)
144-
if let index = index {
145+
if let index = find(animationDidStopQueueEntries, entry) {
145146
animationDidStopQueueEntries.removeAtIndex(index)
146147
}
147148
}

0 commit comments

Comments
 (0)