leftanchor(rightAnchor) vs. leadinganchor(trailingAnchor)
: 문화권에 따라 읽는 방향이 달라서 left & right는 절대방향, leading & trailing은 상대방향
tableViewCell backgroundColor 바꾸기
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "UserTableViewCell", for: indexPath) as! UserTableViewCell
cell.backgroundColor = UIColor(red: 153/255, green: 255/255, blue: 205/255, alpha: 1)
return cell
}
UIButton font 크기 및 굵기 변경
logoutButton.titleLabel?.font = UIFont.systemFont(ofSize: 12, weight: .regular)
되돌아가기
@IBAction func unwindToMain(_ unwindSegue: UIStoryboardSegue) {
}
되돌아갈 때는 위의 코드를 되돌아가고자 하는 뷰컨에서 구현하고 현재 뷰컨에서 exit과 오브젝트를 연결해 줌
segue 없이 다음 씬으로 가기
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let cell = sender as? UITableViewCell {
if let indexPath = userTableView.indexPath(for: cell) {
if let targetViewController = segue.destination as? GameViewController {
targetViewController.opponent = users[indexPath.row]
}
}
}
}
``
extension MainViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let storyboard = UIStoryboard(name: "GameViewController", bundle: nil) //여기서의 스토리보드 이름은 스토리모드 파일명이다 ㅇㅅㅇ;
let inGameVC = storyboard.instantiateViewController(withIdentifier: "GameViewController")
//identifier는 해당 VC의 identity의 storyboard ID
inGameVC.modalPresentationStyle = .fullScreen
self.present(inGameVC, animated: true, completion: nil)
tableView.deselectRow(at: indexPath, animated: true)
}
}