ios7 UITableViewCell selectionStyle won't go back to blue

后端 未结 4 1926
轻奢々
轻奢々 2021-01-30 21:32

Xcode 5.0, iOS 7 and updating an existing app. UITableView selected row is now gray, not blue.

From what I\'ve read they changed the default selection

4条回答
  •  孤街浪徒
    2021-01-30 21:53

    Probably it could help you. I have my custom cell and to make it selected with needed color I have overwrite setHighlighted and setSelected now it's look like that

    #define IOS_7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1 ? YES : NO)
    
    
        - (void)setSelected:(BOOL)selected animated:(BOOL)animated
    {
        [super setSelected:selected animated:animated];
        [self changeSelectionColorForSelectedORHiglightedState:selected];
        // Configure the view for the selected state
    }
    
    - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
    {
        [super setHighlighted:highlighted animated:animated];
        [self changeSelectionColorForSelectedORHiglightedState:highlighted];
    }
    
    - (void)changeSelectionColorForSelectedORHiglightedState:(BOOL)state
    {
        if (IOS_7) {
            if (state) {
                self.contentView.backgroundColor = [UIColor blueColor];
            }
        }
    }
    

提交回复
热议问题