「Swift」UITableViewのセルの区切り線の色を設定する

書式
tableView.separatorColor = .色
tableViewのseparatorColorプロパティに色を指定して区切り線の色を変更します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
class ViewController: UIViewController, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
//線を青くする
tableView.separatorColor = .blue
}
}
class ViewController: UIViewController, UITableViewDataSource { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.dataSource = self //線を青くする tableView.separatorColor = .blue } }
class ViewController: UIViewController, UITableViewDataSource {

  @IBOutlet weak var tableView: UITableView!

  override func viewDidLoad() {
    super.viewDidLoad()

    tableView.dataSource = self
      //線を青くする
    tableView.separatorColor = .blue
  }
}

実行結果
UITableViewの区切線が青くなります。

Swift

Posted by arkgame