@@ -49,15 +49,7 @@ public class RefreshView: UIView {
4949 /// The refresh is completed. The view is now animating out.
5050 case Closing
5151 }
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+
6153
6254 // MARK: - Properties
6355
@@ -80,6 +72,7 @@ public class RefreshView: UIView {
8072 /// The content view displayed when the `scrollView` is pulled down.
8173 public var contentView : ContentView {
8274 willSet {
75+ contentViewMinimumHeightConstraint = nil
8376 contentView. view. removeFromSuperview ( )
8477 }
8578
@@ -105,13 +98,6 @@ public class RefreshView: UIView {
10598 }
10699 }
107100
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-
115101 /// If you need to update the scroll view's content inset while it contains a refresh view, you should set the
116102 /// `defaultContentInset` on the refresh view and it will forward it to the scroll view taking into account the
117103 /// refresh view's position.
@@ -126,7 +112,11 @@ public class RefreshView: UIView {
126112 /// The `contentView`'s `sizeThatFits:` will be respected when displayed but does not effect the expanded height.
127113 /// You can use this to draw outside of the expanded area. If you don't implement `sizeThatFits:` it will
128114 /// 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+ }
130120
131121 /// A boolean indicating if the pull to refresh view is expanded.
132122 public private( set) var isExpanded = false {
@@ -141,15 +131,16 @@ public class RefreshView: UIView {
141131 }
142132 }
143133
144- private var topInset : CGFloat = 0
145-
146134 // Semaphore is used to ensure only one animation plays at a time
147135 private var animationSemaphore : dispatch_semaphore_t = {
148136 let semaphore = dispatch_semaphore_create ( 0 )
149137 dispatch_semaphore_signal ( semaphore)
150138 return semaphore
151139 } ( )
152140
141+ private var topInset : CGFloat = 0
142+ private var contentViewMinimumHeightConstraint : NSLayoutConstraint ?
143+
153144
154145 // MARK: - Initializers
155146
@@ -252,13 +243,14 @@ public class RefreshView: UIView {
252243
253244 contentView. view. translatesAutoresizingMaskIntoConstraints = false
254245
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+
257249 NSLayoutConstraint . activateConstraints ( [
258250 contentView. view. bottomAnchor. constraintEqualToAnchor ( bottomAnchor) ,
259251 contentView. view. leadingAnchor. constraintEqualToAnchor ( leadingAnchor) ,
260252 contentView. view. trailingAnchor. constraintEqualToAnchor ( trailingAnchor) ,
261- contentView . view . heightAnchor . constraintGreaterThanOrEqualToConstant ( expandedHeight )
253+ minumumHeightConstraint
262254 ] )
263255 }
264256
0 commit comments