ios7 UITableViewCell selectionStyle won't go back to blue

后端 未结 4 1928
轻奢々
轻奢々 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:55

    I know this has already been answered but the last thing I wanted to do was touch all of my cellForRowAtIndexPath methods. So, I used an appearance proxy in my App Delegate. I took @null's code above to set the selected background view and in the applicationDidFinishLaunching:withOptions: method I placed this code.

    UIView *bgColorView = [[UIView alloc] init];
    //the rest of null's code to make the view
    [[UITableViewCell appearance] setSelectedBackgroundView:bgColorView];
    

    Then to make the white text hi light:

    [[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] setHighlightedTextColor:[UIColor whiteColor]];
    

    This made a global change in my app. The appearance proxy was introduced in iOS5 and Mattt has a great article on how to use it at his NSHipster blog.

提交回复
热议问题