Move hasBackgroundImage to style object

This commit is contained in:
Roman Efimov
2013-04-04 17:29:08 -05:00
parent d910068f07
commit 726c19c9ff
3 changed files with 14 additions and 13 deletions

View File

@@ -49,7 +49,7 @@
{
self.actionBar = [[REActionBar alloc] initWithDelegate:self];
if ([self hasCustomBackgroundImage]) {
if ([self.tableViewManager.style hasCustomBackgroundImage]) {
self.backgroundView = [[UIView alloc] initWithFrame:self.contentView.bounds];
self.backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_backgroundImageView = [[UIImageView alloc] init];
@@ -71,22 +71,11 @@
}
}
- (BOOL)hasCustomBackgroundImage
{
return [self.tableViewManager.style backgroundImageForCellType:RETableViewCellFirst] || [self.tableViewManager.style backgroundImageForCellType:RETableViewCellMiddle] || [self.tableViewManager.style backgroundImageForCellType:RETableViewCellLast] || [self.tableViewManager.style backgroundImageForCellType:RETableViewCellSingle];
}
- (void)refreshActionBar
{
[self.actionBar.navigationControl setEnabled:[self indexPathForPreviousResponder] != nil forSegmentAtIndex:0];
[self.actionBar.navigationControl setEnabled:[self indexPathForNextResponder] != nil forSegmentAtIndex:1];
}
- (void)layoutSubviews
{
[super layoutSubviews];
if ([self hasCustomBackgroundImage]) {
if ([self.tableViewManager.style hasCustomBackgroundImage]) {
if (self.row == 0 && self.section.items.count == 1) {
_backgroundImageView.image = [self.tableViewManager.style backgroundImageForCellType:RETableViewCellSingle];
}
@@ -107,6 +96,12 @@
}
}
- (void)refreshActionBar
{
[self.actionBar.navigationControl setEnabled:[self indexPathForPreviousResponder] != nil forSegmentAtIndex:0];
[self.actionBar.navigationControl setEnabled:[self indexPathForNextResponder] != nil forSegmentAtIndex:1];
}
- (UIResponder *)responder
{
return nil;

View File

@@ -40,6 +40,7 @@ typedef enum _RETableViewCellType {
@property (assign, readwrite, nonatomic) CGSize textFieldPositionOffset;
@property (assign, readwrite, nonatomic) CGFloat cellHeight;
- (BOOL)hasCustomBackgroundImage;
- (UIImage *)backgroundImageForCellType:(RETableViewCellType)cellType;
- (void)setBackgroundImage:(UIImage *)image forCellType:(RETableViewCellType)cellType;

View File

@@ -40,6 +40,11 @@
return self;
}
- (BOOL)hasCustomBackgroundImage
{
return [self backgroundImageForCellType:RETableViewCellFirst] || [self backgroundImageForCellType:RETableViewCellMiddle] || [self backgroundImageForCellType:RETableViewCellLast] || [self backgroundImageForCellType:RETableViewCellSingle];
}
- (UIImage *)backgroundImageForCellType:(RETableViewCellType)cellType
{
return [_backgroundImages objectForKey:@(cellType)];