ios晋级之路-tableViewCell设置背景颜色

如果你项修改一下cell的颜色的话cell.contentView.backgroundColor = [UIColor redColor];

这样是没有问题的,但是如果你想把其修改成无色,那么就不可以了。

所以

为了改变单元格的背景色,你需要修改:


1

2

3

4

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

    cell.backgroundColor = [UIColor redColor]; 

}

contentView 仅仅是建议 subview 放入自定义控件,这样单元格能在表格编辑时适当的布局。

时间: 2024-07-30 13:18:12

ios晋级之路-tableViewCell设置背景颜色的相关文章

java JFrame 设置背景颜色无效的理解

广州疯狂软件教育Java培训,iOS培训分享 在开发Java应用程序时,通常情况下利用JFrame创建窗口.利用JFrame创建的窗口分别包含一个标题.最小化按钮.最大化按钮和关闭按钮 1.在你使用JFrame创建窗体时的情况: 在你直接调用setBackground(Color.red)这个方法后,你的确设置了JFrame的背景颜色,而你看到的却不是直接的JFrame,而是JFrame.getContentPane().而JFrame上的contentPane默认是Color.WHITE的,所

Pyqt 设置 背景颜色和背景图片

首先设置autoFillBackground属性为真然后定义一个QPalette对象设置QPalette对象的背景属性(颜色或图片)最后设置QWidget对象的Palette 实例: 1 # -*- coding: utf-8 -*- 2 import sys 3 from PyQt4 import QtGui 4 from PyQt4.QtGui import * 5 from PyQt4.QtCore import * 6 7 8 class Icon(QtGui.QWidget): 9 d

每日总结 - android设置背景颜色报错

每天坚持总结,总会发生质变! 今天给radiobutton设置背景颜色报错,信息如下: item> tag requires a 'drawable' attribute or child tag defining a drawable 解决方法: 你不能将颜色选择器用在background上,应该使用drawable selector. 1 <selector xmlns:android="http://schemas.android.com/apk/res/android&quo

Aspose.Cells 设置背景颜色

很多小伙伴设置背景颜色都不起作用,特别提醒需要加入下面一行: style.Pattern = BackgroundType.Solid; Aspose.Cells.Style style = null; int index = workbook.Styles.Add(); style = workbook.Styles[index]; //文本颜色 style.Font.Color = Color.Red; style.Font.Size = 10; //设置背景颜色 style.Foregro

codeblock 设置背景颜色

今天觉得codeblock看着刺眼,想了想,能不能跟vs利用dark背景一样可以设置一个舒服的背景.于是就开始各种点击,各种摸索了. 1. 背景和各种颜色设置 不妨先说下vs中的设置是:工具(Tools) -- 选项(Options) -- 环境(Environment) -- 常规(General) -- 颜色主题(Color theme) -- 深色/浅色(dark or light). codeblock设置背景颜色:settings -- editor -- syntax highlig

css设置背景颜色和处理背景图片样式

<!doctype html><html lang="en"> <head> <meta charset="UTF-8"> <title>css设置背景颜色和处理背景图片样式</title> <style> div{ width:1000px; height:500px;/*没有宽高不能加背景图片*/ border:1px solid #000000; /*background-co

如何为元素设置背景颜色

1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 4 <style type="text/css"> 5 6 body {background-color: yellow} 7 h1 {background-color: #00ff00} 8 h2 {background-color: transparent} 9 p {background-color: rgb(2

tableView和tableViewCell的背景颜色问题

当在tableView中添加cell数据时,我们会发现原本设置的tableView的背景颜色不见了,这是因为加载cell数据时,tableView的背景颜色被cell数据遮盖住了,此时,可以通过设置cell的背景颜色,从而使得界面的背景有颜色 - (void)viewDidLoad { [super viewDidLoad]; //此时不会显示在用户眼前 self.view.backgroundColor = [UIColor blueColor]; } #pragma mark - <UITa

Flutter - 给App增加启动屏幕(Splash Screen)并且设置背景颜色

先看一下效果图,启动图最好设置为png格式的透明图,以防图片填充不满的时候背景图会非常的煞白(Flutter 默认背景色是白色). 打开android\app\src\main\res\drawable\launch_background.xml, <?xml version="1.0" encoding="utf-8"?> <!-- Modify this file to customize your launch splash screen -