2017-02-03 13 views
0

enter image description heretableViewの色を変更しますか?.tableFooterView

私は画像のようにtableViewを作成しました。セクションとセルの間にはスペースがあります。したがって、スペースの色はテーブルビューのデフォルトの色です。

テーブルビュー上の余分な行を削除するために、tableView?.tableFooterViewにUIVIew()を追加しました。

let footerView = UIView() 
self.tableView?.tableFooterView = footerView 

私はUIViewの色を写真の「ターゲットカラー」で同じにします。

私は以下のように試しましたが、動作しません。

let footerView = UIView() 
footerView.backgroundColor = UIColor.black 
footerView.tintColor = UIColor.black 
self.tableView?.tableFooterView = footerView 

どうすればよいですか? ありがとう!

+0

フッタービューの高さを設定しなかった、そしてそれが進むべき道ではない、あなたを設定しているのでnirva Dによって既に言及されているように、テーブル上の希望の色 – TheFuquan

答えて

3

tableViewbackgroundColorを設定してみてください。

self.tableView?.backgroundColor = UIColor.white //Or color that you want 
0

tableviewフッターに異なる色を使用する場合は、別の解決方法があります。

スウィフト4

tableView.tableFooterView = UIView() 
    let screenRect = view.bounds; 
    let screenWidth = screenRect.size.width; 
    let screenHeight = screenRect.size.height; 
    let footerHeight = screenHeight - ((YOUR_SECTION_HEIGHT * SECTION_COUNT) + (YOUR_ROW_HEIGHT * ROW_COUNT)) 
    let footerView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: screenWidth, height: screenHeight - footerHeight)) 
    footerView.backgroundColor = UIColor.darkGray // or your custom color 
    tableView.tableFooterView?.addSubview(footerView) 

のObjective-C

self.tableView.tableFooterView = [[UIView alloc] init]; 
    CGRect screenRect = self.view.bounds; 
    CGFloat screenWidth = screenRect.size.width; 
    CGFloat screenHeight = screenRect.size.height; 
    CGFloat footerHeight = screenHeight - ((YOUR_SECTION_HEIGHT * SECTION_COUNT) + (YOUR_ROW_HEIGHT * ROW_COUNT)); 
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, screenWidth, screenHeight - footerHeight)]; 
    footerView.backgroundColor = [UIColor darkGrayColor]; // or your custom color 
    [self.tableView.tableFooterView addSubview:footerView]; 
関連する問題