私のアプリのテーマの色は緑がかった色なので、次のテーブルビューセルのように、すべてが緑である必要があります。
問題は、[編集]ボタンをクリックすると、セルの左側に小さなマイナス記号がポップアップし、それが緑色ではないことです。
なぜこれが起こるのか分かりません。これは私のコードですcellForRowAtIndexPath
let cell = UITableViewCell()
cell.textLabel?.text = someStuff
cell.textLabel?.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
cell.contentView.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
// Look! here I set the color of the editing accessory!
cell.editingAccessoryView?.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
return cell
ご覧のとおり、テキストラベル、背景、さらにはeditingAccessoryView
!を含め、すべてを緑色に設定しました。しかし、それはただ緑ではありません!あなたが上で見ることができるようにそれは白いままです。
それを緑にするために私が設定しなければならない何か他のものはありますか?
あなたはtableView:willDisplayCell:forRowAtIndexPath:
メソッドでそれをしなければなりません。あなたはそれをこのようにすることができます:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = "MyText"
return cell
}
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.backgroundColor = UIColor(red: 0xca / 0xff, green: 1, blue: 0xc7 / 0xff, alpha: 1)
}
編集:
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加