Skip to content

Commit

Permalink
Update cell label width logic to use the label's own offset rather th…
Browse files Browse the repository at this point in the history
…at a fixed float
  • Loading branch information
tmdvs committed Oct 11, 2017
1 parent 8511b36 commit 8219ff4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TDBadgedCell.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TDBadgedCell'
s.version = '5.2'
s.version = '5.2.1'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'UITableViewCell subclass that adds a "badgeString" property to table view cells.'
s.description = <<-DESC
Expand Down
12 changes: 8 additions & 4 deletions TDBadgedCell/TDBadgedCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ open class TDBadgedCell: UITableViewCell {
badgeView.frame.origin.y = floor((frame.height / 2) - (badgeView.frame.height / 2))

// Now lets update the width of the cells text labels to take the badge into account
let labelWidth = self.contentView.frame.width - (badgeView.frame.width + (offsetX * 2)) - 20;
textLabel?.frame.size.width = labelWidth
if((detailTextLabel) != nil) {
detailTextLabel?.frame.size.width = labelWidth
let labelWidth = self.contentView.frame.width - (badgeView.frame.width + (offsetX * 2));

if textLabel != nil {
textLabel!.frame.size.width = labelWidth - textLabel!.frame.origin.x
}

if detailTextLabel != nil {
detailTextLabel!.frame.size.width = labelWidth - detailTextLabel!.frame.origin.x
}
}

Expand Down

0 comments on commit 8219ff4

Please sign in to comment.