How to change background selected color storyboard static cells

前端 未结 3 1031
眼角桃花
眼角桃花 2021-01-03 00:48

I have an app with storyboard. In one scene I have a tableview with statics cell content. Is possible to change the background selected color to another color out of the def

3条回答
  •  星月不相逢
    2021-01-03 01:22

    You don't need to write neither a single line of code to accomplish that. You can do it all using the storyboard. Just do that:

    1. Add a UIView to your UITableViewCell and link it to the selectedBackgroundView property of the cell (to find this property, you will need to drag the line from the "New Reference Outlet" and release it over the desired UITableViewCell)
    2. Change the color of the UIView to the desired color of the selected state

    You can do the same thing with the backgroundView property. Also, you can use a UIImageView to use a image, instead of the single color background of a UIView.

    Here is a sample file using a custom UIViewController instead of a UITableViewController, but it works on both: http://uxp.com.br/downloads/CustomCell.zip

提交回复
热议问题