Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
Created March 4, 2013 00:12
Show Gist options
  • Save j-mcnally/5079016 to your computer and use it in GitHub Desktop.
Save j-mcnally/5079016 to your computer and use it in GitHub Desktop.
Support for static cells
//
// 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
//
// 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
@ilia3546
Copy link

Please say, how use your solution? =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment