1.給tableviewcell添加label,首先
然後可以定義label的一些屬性
label.backgroundColor = [UIColor grayColor]; //設定背景色
label.text = @"Hello World"; //設定内容
label.textColor = [UIColor blueColor]; //文本顔色
label.backgroundColor = [UIColor clearColor]; //設定label的背景色透明
在這我添加的前三行顔色不一樣
若把[cell.contentView addSubview:label];改為[self.view addSubview:label]則label将建立在tableview中,而不是tableviewcell中
2.給tableviewcell添加button
常用的button的屬性
button.frame = CGRectMake(150,30,50,20);//button的位置
[button setTitle:@"點選" forState:UIControlStateNormal];
button.backgroundColor = [UIColor blackColor];
3在cell建立image
還有一種辦法
用這個辦法該圖檔顯示在cell最左側imageview中