Permalink
Browse files

Added UITableView category for setting up shadows

Only applies to plain table views.
  • Loading branch information...
1 parent 6490f5c commit f5ebb02b65ec228ab1876897a72705f168715735 @vicpenap committed Jun 3, 2012
Showing with 29 additions and 4 deletions.
  1. +1 −4 PrettyExample/PlainExample.m
  2. +15 −0 PrettyKit/PrettyShadowPlainTableview.h
  3. +13 −0 PrettyKit/PrettyShadowPlainTableview.m
@@ -32,9 +32,6 @@ - (void)didReceiveMemoryWarning
// Release any cached data, images, etc that aren't in use.
}
-- (void) setUpShadows {
- [PrettyShadowPlainTableview setUpTableView:self.tableView];
-}
- (void) customizeNavBar {
PrettyNavigationBar *navBar = (PrettyNavigationBar *)self.navigationController.navigationBar;
@@ -66,7 +63,7 @@ - (void)viewDidLoad
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:nil action:nil] autorelease];
- [self setUpShadows];
+ [self.tableView dropShadows];
[self customizeNavBar];
}
@@ -66,3 +66,18 @@ typedef enum {
+ (float) height;
@end
+
+
+/** This category adds a shortcut to drop shadows in both header and footer of
+ a `UITableView`. */
+@interface UITableView (PrettyKitTableViewShadows)
+
+/** Configures automatically the receiver tableView by dropping a shadow in both
+ header and footer. It will also change the tableView's `contentInset` according
+ to the shadows' height.
+
+ Shadows will be included __only__ if the tableView's style is plain.
+ */
+- (void) dropShadows;
+
+@end
@@ -88,3 +88,16 @@ + (float) height {
}
@end
+
+
+@implementation UITableView (PrettyKitTableViewShadows)
+
+- (void) dropShadows
+{
+ if (self.style == UITableViewStylePlain)
+ {
+ [PrettyShadowPlainTableview setUpTableView:self];
+ }
+}
+
+@end

0 comments on commit f5ebb02

Please sign in to comment.