Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 5 commits
  • 9 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jun 12, 2010
digdog Add Icon file b00fd7f
digdog Use dynamic badge text c3d436c
digdog Support editing mode 24bd988
Commits on Nov 04, 2010
digdog Update copyright header, screenshot, and iOS 4-safe project file. b62068f
Commits on Jan 28, 2011
Ching-Lan 'digdog' HUANG 黃 青嵐 Update screenshot URL cb383de
View
21 .gitignore
@@ -0,0 +1,21 @@
+# xcode noise
+*.mode1v3
+*.mode2v3
+*.pbxuser
+*.perspective
+*.perspectivev3
+*.pyc
+*~.nib/
+*.xcworkspace/
+xcuserdata/
+build/*
+
+# Textmate - if you build your xcode projects with it
+*.tm_build_errors
+
+# old skool
+.svn
+
+# osx noise
+.DS_Store
+profile
View
3  DDBadgeViewCell.h
@@ -1,8 +1,9 @@
//
// DDBadgeViewCell.h
+// DDBadgeViewCell
//
// Created by digdog on 1/23/10.
-// Copyright 2010 Ching-Lan 'digdog' HUANG and digdog software. All rights reserved.
+// Copyright 2010 Ching-Lan 'digdog' HUANG. http://digdog.tumblr.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
View
64 DDBadgeViewCell.m
@@ -1,8 +1,9 @@
//
// DDBadgeViewCell.m
+// DDBadgeViewCell
//
// Created by digdog on 1/23/10.
-// Copyright 2010 Ching-Lan 'digdog' HUANG and digdog software. All rights reserved.
+// Copyright 2010 Ching-Lan 'digdog' HUANG. http://digdog.tumblr.com
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -84,30 +85,38 @@ - (void)drawRect:(CGRect)rect {
currentBadgeColor = [UIColor whiteColor];
}
}
-
- CGSize badgeTextSize = [self.cell.badgeText sizeWithFont:[UIFont boldSystemFontOfSize:13.]];
- CGRect badgeViewFrame = CGRectInset(CGRectIntegral(CGRectMake(rect.size.width - badgeTextSize.width - 20, (rect.size.height - badgeTextSize.height) / 2, badgeTextSize.width, badgeTextSize.height)), -7, -2);
-
- CGContextSaveGState(context);
- CGContextSetFillColorWithColor(context, currentBadgeColor.CGColor);
- CGMutablePathRef path = CGPathCreateMutable();
- CGPathAddArc(path, NULL, badgeViewFrame.origin.x + badgeViewFrame.size.width - badgeViewFrame.size.height / 2, badgeViewFrame.origin.y + badgeViewFrame.size.height / 2, badgeViewFrame.size.height / 2, M_PI / 2, M_PI * 3 / 2, YES);
- CGPathAddArc(path, NULL, badgeViewFrame.origin.x + badgeViewFrame.size.height / 2, badgeViewFrame.origin.y + badgeViewFrame.size.height / 2, badgeViewFrame.size.height / 2, M_PI * 3 / 2, M_PI / 2, YES);
- CGContextAddPath(context, path);
- CGContextDrawPath(context, kCGPathFill);
- CFRelease(path);
- CGContextRestoreGState(context);
- CGContextSaveGState(context);
- CGContextSetBlendMode(context, kCGBlendModeClear);
- [self.cell.badgeText drawInRect:CGRectInset(badgeViewFrame, 7, 2) withFont:[UIFont boldSystemFontOfSize:13.]];
- CGContextRestoreGState(context);
-
- [currentSummaryColor set];
- [self.cell.summary drawInRect:CGRectMake(10., 10., badgeViewFrame.origin.x - 15., 22.) withFont:[UIFont boldSystemFontOfSize:18.] lineBreakMode:UILineBreakModeTailTruncation];
-
- [currentDetailColor set];
- [self.cell.detail drawInRect:CGRectMake(10., 32., badgeViewFrame.origin.x - 15., 18.) withFont:[UIFont systemFontOfSize:14.] lineBreakMode:UILineBreakModeTailTruncation];
+ if (self.cell.isEditing) {
+ [currentSummaryColor set];
+ [self.cell.summary drawAtPoint:CGPointMake(10, 10) forWidth:rect.size.width withFont:[UIFont boldSystemFontOfSize:18.] lineBreakMode:UILineBreakModeTailTruncation];
+
+ [currentDetailColor set];
+ [self.cell.detail drawAtPoint:CGPointMake(10, 32) forWidth:rect.size.width withFont:[UIFont systemFontOfSize:14.] lineBreakMode:UILineBreakModeTailTruncation];
+ } else {
+ CGSize badgeTextSize = [self.cell.badgeText sizeWithFont:[UIFont boldSystemFontOfSize:13.]];
+ CGRect badgeViewFrame = CGRectIntegral(CGRectMake(rect.size.width - badgeTextSize.width - 24, (rect.size.height - badgeTextSize.height - 4) / 2, badgeTextSize.width + 14, badgeTextSize.height + 4));
+
+ CGContextSaveGState(context);
+ CGContextSetFillColorWithColor(context, currentBadgeColor.CGColor);
+ CGMutablePathRef path = CGPathCreateMutable();
+ CGPathAddArc(path, NULL, badgeViewFrame.origin.x + badgeViewFrame.size.width - badgeViewFrame.size.height / 2, badgeViewFrame.origin.y + badgeViewFrame.size.height / 2, badgeViewFrame.size.height / 2, M_PI / 2, M_PI * 3 / 2, YES);
+ CGPathAddArc(path, NULL, badgeViewFrame.origin.x + badgeViewFrame.size.height / 2, badgeViewFrame.origin.y + badgeViewFrame.size.height / 2, badgeViewFrame.size.height / 2, M_PI * 3 / 2, M_PI / 2, YES);
+ CGContextAddPath(context, path);
+ CGContextDrawPath(context, kCGPathFill);
+ CFRelease(path);
+ CGContextRestoreGState(context);
+
+ CGContextSaveGState(context);
+ CGContextSetBlendMode(context, kCGBlendModeClear);
+ [self.cell.badgeText drawInRect:CGRectInset(badgeViewFrame, 7, 2) withFont:[UIFont boldSystemFontOfSize:13.]];
+ CGContextRestoreGState(context);
+
+ [currentSummaryColor set];
+ [self.cell.summary drawAtPoint:CGPointMake(10, 10) forWidth:(rect.size.width - badgeViewFrame.size.width - 24) withFont:[UIFont boldSystemFontOfSize:18.] lineBreakMode:UILineBreakModeTailTruncation];
+
+ [currentDetailColor set];
+ [self.cell.detail drawAtPoint:CGPointMake(10, 32) forWidth:(rect.size.width - badgeViewFrame.size.width - 24) withFont:[UIFont systemFontOfSize:14.] lineBreakMode:UILineBreakModeTailTruncation];
+ }
}
@end
@@ -153,6 +162,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
badgeView_ = [[DDBadgeView alloc] initWithFrame:self.contentView.bounds cell:self];
badgeView_.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
badgeView_.contentMode = UIViewContentModeRedraw;
+ badgeView_.contentStretch = CGRectMake(1., 0., 0., 0.);
[self.contentView addSubview:badgeView_];
}
return self;
@@ -178,10 +188,8 @@ - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
-
- [UIView beginAnimations:@"hiddenAnimation" context:NULL];
- self.badgeView.hidden = editing;
- [UIView commitAnimations];
+
+ [self.badgeView setNeedsDisplay];
}
@end
View
4 README.markdown
@@ -2,7 +2,7 @@
DDBadgeViewCell is a UITableViewCell subclass that has a customizable badge view on the right. With fast Quartz 2D path drawing and blending, one can use this with very large data set and still keep great performance when scrolling.
-![](http://github.com/digdog/DDBadgeViewCell/raw/master/screenshot.png)
+![](https://github.com/digdog/DDBadgeViewCell/raw/master/screenshot.png)
## Requirement
@@ -28,4 +28,4 @@ And configure the cell through its properties below:
## License
-DDBadgeViewCell is licensed under MIT license.
+DDBadgeViewCell is released under MIT License.
View
8 Sample/Classes/RootViewController.m
@@ -82,35 +82,29 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
// Configure the cell.
cell.summary = @"Summary";
cell.detail = @"Detail text goes here";
- cell.badgeText = @"Badge Text";
+ cell.badgeText = [NSString stringWithFormat:@"Row %d", indexPath.row];
cell.badgeColor = [UIColor orangeColor];
return cell;
}
-/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
-*/
-
-/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
- [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
-*/
/*
View
2  Sample/DDBadgeView-Info.plist
@@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
- <string></string>
+ <string>Icon.png</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
View
9 Sample/DDBadgeView.xcodeproj/project.pbxproj
@@ -16,6 +16,7 @@
28C286E10D94DF7D0034E888 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C286E00D94DF7D0034E888 /* RootViewController.m */; };
28F335F11007B36200424DE2 /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28F335F01007B36200424DE2 /* RootViewController.xib */; };
771CF05711A0BBE5006420A3 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 771CF05611A0BBE5006420A3 /* QuartzCore.framework */; };
+ 772B1CDD11C44F8100C4C41F /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 772B1CDC11C44F8100C4C41F /* Icon.png */; };
77A2E95011A0BB320054AFE1 /* DDBadgeViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 77A2E94F11A0BB320054AFE1 /* DDBadgeViewCell.m */; };
/* End PBXBuildFile section */
@@ -33,6 +34,7 @@
28F335F01007B36200424DE2 /* RootViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
771CF05611A0BBE5006420A3 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ 772B1CDC11C44F8100C4C41F /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
77A2E94E11A0BB320054AFE1 /* DDBadgeViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDBadgeViewCell.h; path = ../DDBadgeViewCell.h; sourceTree = SOURCE_ROOT; };
77A2E94F11A0BB320054AFE1 /* DDBadgeViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDBadgeViewCell.m; path = ../DDBadgeViewCell.m; sourceTree = SOURCE_ROOT; };
8D1107310486CEB800E47090 /* DDBadgeView-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "DDBadgeView-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
@@ -99,6 +101,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ 772B1CDC11C44F8100C4C41F /* Icon.png */,
28F335F01007B36200424DE2 /* RootViewController.xib */,
28AD735F0D9D9599002E5188 /* MainWindow.xib */,
8D1107310486CEB800E47090 /* DDBadgeView-Info.plist */,
@@ -143,6 +146,7 @@
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DDBadgeView" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
@@ -167,6 +171,7 @@
files = (
28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */,
28F335F11007B36200424DE2 /* RootViewController.xib in Resources */,
+ 772B1CDD11C44F8100C4C41F /* Icon.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -223,7 +228,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
- SDKROOT = iphoneos4.0;
+ SDKROOT = iphoneos;
};
name = Debug;
};
@@ -237,7 +242,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PREBINDING = NO;
- SDKROOT = iphoneos4.0;
+ SDKROOT = iphoneos;
};
name = Release;
};
View
BIN  Sample/Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

No commit comments for this range

Something went wrong with that request. Please try again.