@@ -49,15 +49,7 @@ public class RefreshView: UIView {
49
49
/// The refresh is completed. The view is now animating out.
50
50
case Closing
51
51
}
52
-
53
- public enum Style {
54
- /// The view is attachted to the scroll view and pulls with the scroll view content.
55
- case Scrolling
56
-
57
- /// The view is stationary behind the scroll view content (like the system UIRefreshControl).
58
- case Stationary
59
- }
60
-
52
+
61
53
62
54
// MARK: - Properties
63
55
@@ -80,6 +72,7 @@ public class RefreshView: UIView {
80
72
/// The content view displayed when the `scrollView` is pulled down.
81
73
public var contentView : ContentView {
82
74
willSet {
75
+ contentViewMinimumHeightConstraint = nil
83
76
contentView. view. removeFromSuperview ( )
84
77
}
85
78
@@ -105,13 +98,6 @@ public class RefreshView: UIView {
105
98
}
106
99
}
107
100
108
- /// A refresh view style. The default is `.Scrolling`.
109
- public private( set) var style : Style = . Scrolling {
110
- didSet {
111
- // TODO: Update constraints
112
- }
113
- }
114
-
115
101
/// If you need to update the scroll view's content inset while it contains a refresh view, you should set the
116
102
/// `defaultContentInset` on the refresh view and it will forward it to the scroll view taking into account the
117
103
/// refresh view's position.
@@ -126,7 +112,11 @@ public class RefreshView: UIView {
126
112
/// The `contentView`'s `sizeThatFits:` will be respected when displayed but does not effect the expanded height.
127
113
/// You can use this to draw outside of the expanded area. If you don't implement `sizeThatFits:` it will
128
114
/// automatically display at the default size.
129
- public var expandedHeight : CGFloat = 64
115
+ public var expandedHeight : CGFloat = 64 {
116
+ didSet {
117
+ contentViewMinimumHeightConstraint? . constant = expandedHeight
118
+ }
119
+ }
130
120
131
121
/// A boolean indicating if the pull to refresh view is expanded.
132
122
public private( set) var isExpanded = false {
@@ -141,15 +131,16 @@ public class RefreshView: UIView {
141
131
}
142
132
}
143
133
144
- private var topInset : CGFloat = 0
145
-
146
134
// Semaphore is used to ensure only one animation plays at a time
147
135
private var animationSemaphore : dispatch_semaphore_t = {
148
136
let semaphore = dispatch_semaphore_create ( 0 )
149
137
dispatch_semaphore_signal ( semaphore)
150
138
return semaphore
151
139
} ( )
152
140
141
+ private var topInset : CGFloat = 0
142
+ private var contentViewMinimumHeightConstraint : NSLayoutConstraint ?
143
+
153
144
154
145
// MARK: - Initializers
155
146
@@ -252,13 +243,14 @@ public class RefreshView: UIView {
252
243
253
244
contentView. view. translatesAutoresizingMaskIntoConstraints = false
254
245
255
- // TODO: Updated height contraint with expandedHeight changes
256
- // TODO: Support stationary style
246
+ let minumumHeightConstraint = contentView. view. heightAnchor. constraintGreaterThanOrEqualToConstant ( expandedHeight)
247
+ contentViewMinimumHeightConstraint = minumumHeightConstraint
248
+
257
249
NSLayoutConstraint . activateConstraints ( [
258
250
contentView. view. bottomAnchor. constraintEqualToAnchor ( bottomAnchor) ,
259
251
contentView. view. leadingAnchor. constraintEqualToAnchor ( leadingAnchor) ,
260
252
contentView. view. trailingAnchor. constraintEqualToAnchor ( trailingAnchor) ,
261
- contentView . view . heightAnchor . constraintGreaterThanOrEqualToConstant ( expandedHeight )
253
+ minumumHeightConstraint
262
254
] )
263
255
}
264
256
0 commit comments