سؤال

In general Storyboards are an awesome hugely productive tool that I cannot live without. But ... I am pulling my hair out trying to do something I assumed would be trivially simple: set the selection color for a tableView cell. Impossible.

My storyboard is simple: navigationController --root controller--> tableViewController

Here are screenshots.

The app. Notice the pale, sickly grey cell selection color that should be blue. enter image description here

Storyboard screenshots.

NavigationController. Notice I set the nav bar to opaque.

enter image description here

TableViewController. Again, solid opaque nav bar. enter image description here

TableViewCell. Notice I set selection color to blue not pale, sickly grey. enter image description here

Can someone please explain to me how to convince Storyboard how to do this.

Thanks.

هل كانت مفيدة؟

المحلول

In your storyboard, do the following:

  1. Place a UIView as a background view of your prototype cell. This should be below your UILabels. Change its background color to your desired color. (Background NOT Tint)

  2. Select your prototype cell and go to its connections inspector (Command + Alt + 6).

  3. Drag the selectedBackgroundView outlet into your just placed background view.

Source: How to change background selected color storyboard static cells

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top