How to get user-defined background color in three 20 TTTableViewController

having an instance of TTTableViewController, I'm trying to set the background of the current selected cell. I know the concept of styles in Three20, but it just suggests:

- (UITableViewCellSelectionStyle)tableSelectionStyle {
    return UITableViewCellSelectionStyleGray;
}

with standard parameters UITableViewCellSelectionStyleNone, UITableViewCellSelectionStyleBlue, UITableViewCellSelectionStyleGray.

Secondly, I know that UITableView implementations will simply take subclasses of UITableViewCell. One could set selectedBackgroundView of this cell class:

UIView *myBackView = [[UIView alloc] initWithFrame:self.frame];
myBackView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
self.selectedBackgroundView = myBackView;
[myBackView release];

How to set background color for selected cell in TT20TTTViewViewController instance?

+3
source share
1 answer

. three20UI.xcodeproj , UITableViewCell, , , .

, , TTSectionedDataSource, , , MySectionedDataSource, - :

     - (void)tableView:(UITableView*)tableView 
                  cell:(UITableViewCell*)cell 
 willAppearAtIndexPath:(NSIndexPath*)indexPath { 

            UIView *view = [[UIView alloc] initWithFrame: CGRectMake(cell.frame.origin.x, cell.frame.origin.y, cell.width, cell.height)]; 
               view.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1]; 
               cell.selectedBackgroundView = view; 
     } 

.

selectedBackgroundView

 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

, , . , , , , - , , bg, . , ...:)

.

+1

Source: https://habr.com/ru/post/1763341/


All Articles