@@ -88,7 +88,7 @@ public class WSTagsField: UIView {
8888 }
8989 }
9090
91- public var padding : UIEdgeInsets = UIEdgeInsets ( top: 10.0 , left: 8.0 , bottom: 10.0 , right: 16 .0) {
91+ public var padding : UIEdgeInsets = UIEdgeInsets ( top: 10.0 , left: 8.0 , bottom: 10.0 , right: 8 .0) {
9292 didSet {
9393 repositionViews ( )
9494 }
@@ -181,7 +181,7 @@ public class WSTagsField: UIView {
181181 }
182182
183183 public override func intrinsicContentSize( ) -> CGSize {
184- return CGSize ( width: UIViewNoIntrinsicMetric , height: max ( 45 , self . intrinsicContentHeight) )
184+ return CGSize ( width: self . frame . size . width - padding . left - padding . right , height: max ( 45 , self . intrinsicContentHeight) )
185185 }
186186
187187 private func repositionViews( ) {
@@ -195,7 +195,7 @@ public class WSTagsField: UIView {
195195 // Position Tag views
196196 var tagRect = CGRect . null
197197 for tagView in tagViews {
198- tagRect = tagView. frame
198+ tagRect = CGRect ( origin : CGPoint . zero , size : tagView. sizeToFit ( self . intrinsicContentSize ( ) ) )
199199
200200 let tagBoundary = isOnFirstLine ? firstLineRightBoundary : rightBoundary
201201 if curX + CGRectGetWidth( tagRect) > tagBoundary {
@@ -210,6 +210,7 @@ public class WSTagsField: UIView {
210210 // Center our tagView vertically within STANDARD_ROW_HEIGHT
211211 tagRect. origin. y = curY + ( ( WSTagsField . STANDARD_ROW_HEIGHT - CGRectGetHeight( tagRect) ) / 2.0 )
212212 tagView. frame = tagRect
213+ tagView. setNeedsLayout ( )
213214
214215 curX = CGRectGetMaxX ( tagRect) + WSTagsField. HSPACE + self . spaceBetweenTags
215216 }
@@ -279,7 +280,6 @@ public class WSTagsField: UIView {
279280 return self . textField. editing
280281 }
281282
282-
283283 public func beginEditing( ) {
284284 self . textField. becomeFirstResponder ( )
285285 self . unselectAllTagViewsAnimated ( false )
0 commit comments