Today I made a brief example, using tableView to implement the excel freeze pane function Demo:/sunflowrs/
Initialize Tableview to implement proxy
class BasicTableView:UITableView,UITableViewDelegate,UITableViewDataSource
When declaring variables, arrays and dictionaries are best set to known types to avoid trouble
var titleArr:Array<String> = [] var listArr:Array<Dictionary<String,String>> = []
Use the override keyword when rewriting the parent class method
override func awakeFromNib() { () = self = self = = false }
It is important to note: to avoid popularity, you must implement two methods
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var identifierStr :String if == 1001 { identifierStr = "tableViewCell" }else{ identifierStr = "tableViewCell2" } var cell:UITableViewCell = () if (nil){ cell = (style: , reuseIdentifier: identifierStr) } if %2 == 0{ = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0) }else{ = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1) } if == 1001 { !.text = String(describing: titleArr[ ]) ?.textAlignment = ?.font = (ofSize: 14) if == 0 { ?.textColor = UIColor (colorLiteralRed: 16/255.0, green: 86/255.0, blue: 186/255.0, alpha: 1.0) }else{ ?.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1) } }else{ for (idx,value) in () { let label:UILabel = (frame: CGRect(x:idx*60,y:0,width:60,height: Int())) = = (ofSize: 14.0) if == 0 { = UIColor (colorLiteralRed: 16/255.0, green: 86/255.0, blue: 186/255.0, alpha: 1.0) }else{ = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1) } .addSubview(label) if idx == -1{ = CGRect(x:,y:,width:+,height:) } switch () { case 0: = value["date"]! + "day" case 1: = value["total"] case 2: = value["projectCount"] case 3: = value["visitrate"] case 4: = value["abandonCount"] case 5: = value["abandonrate"] default: = "" } } } return cell; }
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.