2017-07-01 8 views
1

コンテンツを持つセルで終了するタイムラインビューを持つテーブルビューコントローラを作成しました。 テーブルビューの縦線は、配列から2つのリストを引っ張っているので、tableviewの2番目の行で終わりますが、その代わりに、縦線を下端まで表示し、円を未使用テーブルビューセル。プログラムでビューを作成しました。カスタムテーブルビューのセルは次のようになりますテーブルビュー全体をカバーするタイムラインビューを作成する

private func setUpTimeline(){ 

     addSubview(bezierLine) 

     bezierLine.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 92.5).isActive = true 
     bezierLine.topAnchor.constraint(equalTo: self.topAnchor).isActive = true 
     bezierLine.widthAnchor.constraint(equalToConstant: 0.8).isActive = true 
     bezierLine.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true 


     addSubview(circularCompletion) 

     circularCompletion.leftAnchor.constraint(equalTo: self.bezierLine.leftAnchor, constant: -12.5).isActive = true 
     circularCompletion.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true 
     circularCompletion.widthAnchor.constraint(equalToConstant: 25).isActive = true 
     circularCompletion.heightAnchor.constraint(equalToConstant: 25).isActive = true 


     addSubview(timeLabel) 
     timeLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true 
     timeLabel.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 8).isActive = true 
     timeLabel.rightAnchor.constraint(equalTo: self.bezierLine.leftAnchor).isActive = true 
     timeLabel.heightAnchor.constraint(equalToConstant: 30).isActive = true 


     addSubview(surveyNameLabel) 
     surveyNameLabel.leftAnchor.constraint(equalTo: self.bezierLine.rightAnchor, constant: 18).isActive = true 
     surveyNameLabel.topAnchor.constraint(equalTo: self.circularCompletion.topAnchor).isActive = true 
     surveyNameLabel.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true 
     surveyNameLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true 

     addSubview(surveyDetailsLabel) 
     surveyDetailsLabel.leftAnchor.constraint(equalTo: self.surveyNameLabel.leftAnchor).isActive = true 
     surveyDetailsLabel.topAnchor.constraint(equalTo: self.surveyNameLabel.bottomAnchor, constant: 8).isActive = true 
     surveyDetailsLabel.rightAnchor.constraint(equalTo: self.surveyNameLabel.rightAnchor).isActive = true 
     surveyDetailsLabel.heightAnchor.constraint(equalToConstant: 15).isActive = true 
    } 
+0

残りの部分については、その行をフッタービューに入れるのはどうですか? – Larme

答えて

0

これは実際には非常に簡単でした。私は、UIViewから継承し、Tableviewデータソース、デリゲートに従うクラスを作成しました。このブロックを作成し、

lazy var table: UITableView = { 
     var bounds = UIScreen.main.bounds 
     let tv = UITableView(frame:CGRect(x: 0, y: 0, width: bounds.width, height: 800)) 
     tv.backgroundColor = UIColor.red 
     tv.separatorColor = UIColor.clear 
     tv.dataSource = self 
     tv.delegate = self 
     return tv 
    }() 

はその後、メインビューコントローラで

override init(frame: CGRect) { 
     super.init(frame: frame) 
     addSubview(table) 

     table.register(EmptyTableViewCells.self, forCellReuseIdentifier: cellId) 
    } 

をカスタムセルを登録し、私は「surveyFooter」と呼ばれるクラスのインスタンスを作成し、tableFooterViewにこれを追加しました。

self.tableView.tableFooterView = surveyFooter 
関連する問題