I am using the library https://github.com/xmartlabs/XLActionController in order to create a custom action sheet. Everything works but I cannot find the way to change the color of the cell.
I have managed to change the background CollectionView
color but I cannot figure out how to change the color of just the cell.
let actionController = SkypeActionController()
actionController.settings.statusBar.showStatusBar = false
actionController.collectionView.backgroundColor = mySavedColor
actionController.addAction(Action(AlertString, style: .Default, handler: { action in
}))
In the case of the SkypeCell
, you have to change its initialize
function. Look for backgroundColor = .clearColor()
and then put the color you're using.
In a general case, you can change the cell's backgroundColor when onConfigureCellForAction
is called. You can set a block to this of your ActionController
:
public override init(nibName nibNameOrNil: String? = nil, bundle nibBundleOrNil: NSBundle? = nil) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
// Do other setup
onConfigureCellForAction = { cell, action, indexPath in
cell.backgroundColor = .redColor()
}
}
Alternatively, you should be able to do the same in the xib file of your cell.
Using the last version (3.0.0) of the library XLActionController and Swift 3, you have the option to change the background color using this code:
let actionController = SkypeActionController()
actionController.backgroundColor = .red
It is a new feature in this version of the library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.