diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8bf2f0b --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Tim Davies (http://tmdvs.me) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/TDBadgedCell (xcode project)/Classes/RootViewController.m b/TDBadgedCell (xcode project)/Classes/RootViewController.m index 86f795e..7dba339 100644 --- a/TDBadgedCell (xcode project)/Classes/RootViewController.m +++ b/TDBadgedCell (xcode project)/Classes/RootViewController.m @@ -112,7 +112,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N if (indexPath.row == 2) { cell.badgeColor = [UIColor colorWithRed:0.197 green:0.592 blue:0.219 alpha:1.000]; - cell.badge.radius = 12; + cell.badge.radius = 1; cell.badge.fontSize = 17; } diff --git a/TDBadgedCell (xcode project)/TDBadgedCell.m b/TDBadgedCell (xcode project)/TDBadgedCell.m index a5df4f2..d731918 100755 --- a/TDBadgedCell (xcode project)/TDBadgedCell.m +++ b/TDBadgedCell (xcode project)/TDBadgedCell.m @@ -211,6 +211,18 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { + self.badgeLeftOffset = 10.f; + + if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) { + if (self.accessoryType != UITableViewCellAccessoryNone) { + + self.badgeRightOffset = 0.f; + } else { + + self.badgeRightOffset = 12.f; + } + } + [self configureSelf]; } return self; @@ -224,10 +236,6 @@ - (void)configureSelf self.badge.parent = self; - - self.badgeLeftOffset = 10.f; - self.badgeRightOffset = 12.f; - // by default, resize textLabel & detailTextLabel self.resizeableLabels = [NSMutableArray arrayWithCapacity:2]; if (self.textLabel != nil) @@ -268,15 +276,6 @@ - (void) layoutSubviews else [self.badge setHidden:NO]; - if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) { - if (self.accessoryType != UITableViewCellAccessoryNone) { - - self.badgeRightOffset = 0.f; - } else { - - self.badgeRightOffset = 12.f; - } - } // Calculate the size of the bage from the badge string UIFont *font = self.badge.boldFont ? [UIFont boldSystemFontOfSize:self.badge.fontSize] : [UIFont systemFontOfSize:self.badge.fontSize]; @@ -286,6 +285,7 @@ - (void) layoutSubviews } else { badgeSize = [self.badgeString sizeWithFont:font]; } + CGRect badgeframe = CGRectMake(self.contentView.frame.size.width - (badgeSize.width + 13 + self.badgeRightOffset), (CGFloat)round((self.contentView.frame.size.height - (badgeSize.height + (50/badgeSize.height))) / 2), badgeSize.width + 13, badgeSize.height + (50/badgeSize.height));