Created
March 4, 2013 00:12
-
-
Save j-mcnally/5079016 to your computer and use it in GitHub Desktop.
Support for static cells
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PrettyTableViewCell+StaticCells.h | |
// | |
// | |
// Created by Justin McNally on 3/3/13. | |
// Copyright (c) 2013 Kohactive. All rights reserved. | |
// | |
@interface PrettyTableViewCell (StaticCells) | |
-(void) initializeVars; | |
@end | |
@interface PrettyTableViewCellBackground : UIView | |
@property (nonatomic, assign) PrettyTableViewCell *cell; | |
-(id)initWithFrame:(CGRect)frame behavior:(int)behavior; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PrettyTableViewCell+StaticCells.m | |
// | |
// Created by Justin McNally on 3/3/13. | |
// Copyright (c) 2013 Kohactive. All rights reserved. | |
// | |
#import "PrettyTableViewCell+StaticCells.h" | |
typedef enum { | |
CellBackgroundBehaviorNormal = 0, | |
CellBackgroundBehaviorSelected, | |
} CellBackgroundBehavior; | |
@implementation PrettyTableViewCell (StaticCells) | |
- (id)initWithCoder:(NSCoder *)aDecoder { | |
self = [super initWithCoder:aDecoder]; | |
if (self) { | |
[self.contentView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionOld context:nil]; | |
PrettyTableViewCellBackground *bg = [[PrettyTableViewCellBackground alloc] initWithFrame:self.frame | |
behavior:CellBackgroundBehaviorNormal]; | |
bg.cell = self; | |
self.backgroundView = bg; | |
[bg release]; | |
bg = [[PrettyTableViewCellBackground alloc] initWithFrame:self.frame | |
behavior:CellBackgroundBehaviorSelected]; | |
bg.cell = self; | |
self.selectedBackgroundView = bg; | |
[bg release]; | |
[self initializeVars]; | |
} | |
return self; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please say, how use your solution? =)