Skip to content

Commit 8219ff4

Browse files
committed
Update cell label width logic to use the label's own offset rather that a fixed float
1 parent 8511b36 commit 8219ff4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

TDBadgedCell.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'TDBadgedCell'
3-
s.version = '5.2'
3+
s.version = '5.2.1'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'UITableViewCell subclass that adds a "badgeString" property to table view cells.'
66
s.description = <<-DESC

TDBadgedCell/TDBadgedCell.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ open class TDBadgedCell: UITableViewCell {
5656
badgeView.frame.origin.y = floor((frame.height / 2) - (badgeView.frame.height / 2))
5757

5858
// Now lets update the width of the cells text labels to take the badge into account
59-
let labelWidth = self.contentView.frame.width - (badgeView.frame.width + (offsetX * 2)) - 20;
60-
textLabel?.frame.size.width = labelWidth
61-
if((detailTextLabel) != nil) {
62-
detailTextLabel?.frame.size.width = labelWidth
59+
let labelWidth = self.contentView.frame.width - (badgeView.frame.width + (offsetX * 2));
60+
61+
if textLabel != nil {
62+
textLabel!.frame.size.width = labelWidth - textLabel!.frame.origin.x
63+
}
64+
65+
if detailTextLabel != nil {
66+
detailTextLabel!.frame.size.width = labelWidth - detailTextLabel!.frame.origin.x
6367
}
6468
}
6569

0 commit comments

Comments
 (0)