我从互联网上添加了这段代码及其工作原理。它显示了两个按钮时,滑动单元格,但按钮都是红色的。为什么?我该怎么换呢?

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
// 1
var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Aceitar" , handler: { ( action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
// 2
let shareMenu = UIAlertController(title: nil, message: "Confirmar Aceitação", preferredStyle: .ActionSheet)
let twitterAction = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)
shareMenu.addAction(twitterAction)
shareMenu.addAction(cancelAction)
self.presentViewController(shareMenu, animated: true, completion: nil)
})
// 3
var rateAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Recusar" , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
// 4
let rateMenu = UIAlertController(title: nil, message: "Confirmar Recusa", preferredStyle: .ActionSheet)
let appRateAction = UIAlertAction(title: "Confirmo", style: UIAlertActionStyle.Default, handler: nil)
let cancelAction = UIAlertAction(title: "Cancelar", style: UIAlertActionStyle.Cancel, handler: nil)
rateMenu.addAction(appRateAction)
rateMenu.addAction(cancelAction)
self.presentViewController(rateMenu, animated: true, completion: nil)
})
// 5
return [shareAction,rateAction]
}发布于 2015-08-28 14:12:30
您可以使用backgroundColor属性的UITableViewRowAction。例如,rateAction.backgroundColor = UIColor.blueColor()。
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Aceitar" , handler: {(action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
// Put your shareAction handler stuff here
})
var rateAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Recusar" , handler: {(action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
// Put your rateAction handler stuff here
})
shareAction.backgroundColor = UIColor.redColor()
rateAction.backgroundColor = UIColor.blueColor()
return [shareAction, rateAction]
}https://stackoverflow.com/questions/32272933
复制相似问题