GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Selected background image view · zhmios/RETableViewManager@77d2fb8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • RETableViewManager
    • Cells
      • RETableViewDateTimeCell.m
    • RETableViewCell.h
    • RETableViewCell.m
    • RETableViewCellStyle.h
    • RETableViewCellStyle.m
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎RETableViewManager/Cells/RETableViewDateTimeCell.m‎

Copy file name to clipboardExpand all lines: RETableViewManager/Cells/RETableViewDateTimeCell.m
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
//
88

99
#import "RETableViewDateTimeCell.h"
10+
#import "RETableViewManager.h"
1011

1112
@implementation RETableViewDateTimeCell
1213

1314
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
1415
{
1516
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1617
if (self) {
17-
self.selectionStyle = UITableViewCellSelectionStyleBlue;
1818
self.textLabel.backgroundColor = [UIColor clearColor];
1919
}
2020
return self;
@@ -23,7 +23,7 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
2323
- (void)cellDidLoad
2424
{
2525
[super cellDidLoad];
26-
26+
self.selectionStyle = self.tableViewManager.style.defaultCellSelectionStyle;
2727
}
2828

2929
- (void)cellWillAppear
Collapse file

‎RETableViewManager/RETableViewCell.h‎

Copy file name to clipboardExpand all lines: RETableViewManager/RETableViewCell.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
@interface RETableViewCell : UITableViewCell <REActionBarDelegate>
3434

3535
@property (strong, readonly, nonatomic) UIImageView *backgroundImageView;
36+
@property (strong, readonly, nonatomic) UIImageView *selectedBackgroundImageView;
3637
@property (assign, readwrite, nonatomic) NSInteger row;
3738
@property (assign, readwrite, nonatomic) NSInteger sectionIndex;
3839
@property (weak, readwrite, nonatomic) UITableView *parentTableView;
Collapse file

‎RETableViewManager/RETableViewCell.m‎

Copy file name to clipboardExpand all lines: RETableViewManager/RETableViewCell.m
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ - (void)cellDidLoad
5555
_backgroundImageView = [[UIImageView alloc] init];
5656
[self.backgroundView addSubview:_backgroundImageView];
5757
}
58+
59+
if ([self.tableViewManager.style hasCustomSelectedBackgroundImage]) {
60+
self.selectedBackgroundView = [[UIView alloc] initWithFrame:self.contentView.bounds];
61+
self.selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
62+
_selectedBackgroundImageView = [[UIImageView alloc] init];
63+
[self.selectedBackgroundView addSubview:_selectedBackgroundImageView];
64+
}
5865
}
5966

6067
- (void)cellWillAppear
@@ -90,6 +97,22 @@ - (void)layoutSubviews
9097

9198
_backgroundImageView.frame = CGRectMake(0, 0, _backgroundImageView.image.size.width, _backgroundImageView.image.size.height);
9299
}
100+
101+
if ([self.tableViewManager.style hasCustomSelectedBackgroundImage]) {
102+
if (self.row == 0 && self.section.items.count == 1)
103+
_selectedBackgroundImageView.image = [self.tableViewManager.style selectedBackgroundImageForCellType:RETableViewCellSingle];
104+
105+
if (self.row == 0 && self.section.items.count > 1)
106+
_selectedBackgroundImageView.image = [self.tableViewManager.style selectedBackgroundImageForCellType:RETableViewCellFirst];
107+
108+
if (self.row > 0 && self.row < self.section.items.count - 1 && self.section.items.count > 2)
109+
_selectedBackgroundImageView.image = [self.tableViewManager.style selectedBackgroundImageForCellType:RETableViewCellMiddle];
110+
111+
if (self.row == self.section.items.count - 1 && self.section.items.count > 1)
112+
_selectedBackgroundImageView.image = [self.tableViewManager.style selectedBackgroundImageForCellType:RETableViewCellLast];
113+
114+
_selectedBackgroundImageView.frame = CGRectMake(0, 0, _selectedBackgroundImageView.image.size.width, _selectedBackgroundImageView.image.size.height);
115+
}
93116
}
94117

95118
- (void)updateActionBarNavigationControl
Collapse file

‎RETableViewManager/RETableViewCellStyle.h‎

Copy file name to clipboardExpand all lines: RETableViewManager/RETableViewCellStyle.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ typedef enum _RETableViewCellType {
3434

3535
@interface RETableViewCellStyle : NSObject {
3636
NSMutableDictionary *_backgroundImages;
37+
NSMutableDictionary *_selectedBackgroundImages;
3738
}
3839

3940
@property (strong, readwrite, nonatomic) UIFont *textFieldFont;
4041
@property (assign, readwrite, nonatomic) CGSize textFieldPositionOffset;
4142
@property (assign, readwrite, nonatomic) CGFloat cellHeight;
43+
@property (assign, readwrite, nonatomic) UITableViewCellSelectionStyle defaultCellSelectionStyle;
4244

4345
- (BOOL)hasCustomBackgroundImage;
4446
- (UIImage *)backgroundImageForCellType:(RETableViewCellType)cellType;
4547
- (void)setBackgroundImage:(UIImage *)image forCellType:(RETableViewCellType)cellType;
4648

49+
- (BOOL)hasCustomSelectedBackgroundImage;
50+
- (UIImage *)selectedBackgroundImageForCellType:(RETableViewCellType)cellType;
51+
- (void)setSelectedBackgroundImage:(UIImage *)image forCellType:(RETableViewCellType)cellType;
52+
4753
@end
Collapse file

‎RETableViewManager/RETableViewCellStyle.m‎

Copy file name to clipboardExpand all lines: RETableViewManager/RETableViewCellStyle.m
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ - (id)init
3434
return nil;
3535

3636
_backgroundImages = [[NSMutableDictionary alloc] init];
37+
_selectedBackgroundImages = [[NSMutableDictionary alloc] init];
3738
_textFieldFont = [UIFont systemFontOfSize:16];
3839
_cellHeight = 44;
40+
_defaultCellSelectionStyle = UITableViewCellSelectionStyleBlue;
3941

4042
return self;
4143
}
@@ -56,4 +58,20 @@ - (void)setBackgroundImage:(UIImage *)image forCellType:(RETableViewCellType)cel
5658
[_backgroundImages setObject:image forKey:@(cellType)];
5759
}
5860

61+
- (BOOL)hasCustomSelectedBackgroundImage
62+
{
63+
return [self selectedBackgroundImageForCellType:RETableViewCellFirst] || [self selectedBackgroundImageForCellType:RETableViewCellMiddle] || [self selectedBackgroundImageForCellType:RETableViewCellLast] || [self selectedBackgroundImageForCellType:RETableViewCellSingle];
64+
}
65+
66+
- (UIImage *)selectedBackgroundImageForCellType:(RETableViewCellType)cellType
67+
{
68+
return [_selectedBackgroundImages objectForKey:@(cellType)];
69+
}
70+
71+
- (void)setSelectedBackgroundImage:(UIImage *)image forCellType:(RETableViewCellType)cellType
72+
{
73+
if (image)
74+
[_selectedBackgroundImages setObject:image forKey:@(cellType)];
75+
}
76+
5977
@end

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.