iOS/iOS SeSAC 2기 TIL

2차 평가과제 중 알게된 것들 (테이블뷰 섹션 관련)

Developer-Michelle 2022. 9. 2. 16:11

TableView Section뒤에 배경화면을 UIViewController의 배경화면으로 하고싶을 때 (비우고 싶은 경우)

[self.tableView setBackgroundView:nil];
[self.tableView setBackgroundColor:[UIColor clearColor]];

 

https://stackoverflow.com/questions/18753411/uitableview-clear-background

 

UITableView clear background

I realize that iOS 7 has not officially been released and we should not discuss it BUT I am going crazy trying to figure out this problem. On iOS 6, my table view was transparent and looked great. ...

stackoverflow.com

 

 

TableView Header의 text 색상을 하얀색으로 바꾸고 싶은 경우

func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int){
    view.tintColor = UIColor.red
    let header = view as! UITableViewHeaderFooterView
    header.textLabel?.textColor = UIColor.white
}

 

https://stackoverflow.com/questions/813068/uitableview-change-section-header-color

 

UITableView - change section header color

How can I change color of a section header in UITableView? EDIT: The answer provided by DJ-S should be considered for iOS 6 and above. The accepted answer is out of date.

stackoverflow.com

 

TableView Header의 text size를 바꾸고 싶은 경우

override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
    guard let header = view as? UITableViewHeaderFooterView else { return }
    header.textLabel?.textColor = UIColor.red
    header.textLabel?.font = UIFont.boldSystemFont(ofSize: 18)
    header.textLabel?.frame = header.bounds
    header.textLabel?.textAlignment = .center
}

https://stackoverflow.com/questions/19802336/changing-font-size-for-uitableview-section-headers

 

Changing Font Size For UITableView Section Headers

Can someone please instruct me on the easiest way to change the font size for the text in a UITableView section header? I have the section titles implemented using the following method: - (NSStri...

stackoverflow.com

 

TableView Header의 너비를 바꾸고 싶은 경우

var textView = UITextView(frame: CGRect(x: 0, y: 0, width: cell.frame.size.width, height: cell.frame.size.height))

https://www.appsloveworld.com/swift/100/114/swift-how-do-i-programmatically-add-and-resize-textview-to-cell

 

[Solved]-Swift: How do I programmatically add and resize textView to cell?-swift

Coding example for the question Swift: How do I programmatically add and resize textView to cell?-swift

www.appsloveworld.com