Actions - LowKostKustomz/ActionsList GitHub Wiki
To add action to list you should first create ActionsListDefaultButtonModel
's instance
let action = ActionsListDefaultButtonModel(
localizedTitle: "Action title",
image: UIImage(named: "Image name"),
action: { (action) in
// Perform actions (some examples below)
},
isEnabled: true
)
and add it to list model
list.add(action: action)
Parameters
Localized title
Text to show in button. Should be localized.
Image
Optional, should be 35x35 for @1x size. Displayed on left or right of the button depending on side actions list was shown in.
Action
Optional, action to perform on .touchUpInside
. Passes action model instance.
If action is enabled
Default true
, changes button's appearance and if the button can be highlighted. Action called not depending on this property (see examples below).
Appearance
You can customize action's appearance via the ActionsListDefaultButtonModel
's appearance
property or edit ActionsListAppearance.Button.common
to change default button appearance.
All appearance properties
Highlighted background color
public var highlightedBackgroundColor: UIColor
Used for button's background color when it is highlighted.
Background color
public var backgroundColor: UIColor
Used for normal button's background color.
Tint color
public var tint: UIColor
Used as
textColor
for title andtintColor
for image (if image is in template mode).
Highlighted tint color
public var highlightedTint: UIColor
Tint color used when button is highlighted
Disabled tint color
public var disabledTint: UIColor
Tint color used when button is disabled
Title font
public var font: UIFont
Font used for button's text
Feedback generation
See Feedback Generator for details
Possible actions examples
You can manage list via ActionsListDefaultButtonModel
's list
property
// To dismiss
action.list?.dismiss({
// Dismiss completion
})
Also you can edit actions
// To change action's appearance
action.appearance.doWhatEverYouWant()
action.list?.reloadActions() // You should call this method to apply changes while showing list. This method does not affect list's appearance.
// To change action availability
action.isEnabled = !action.isEnabled
action.list?.reloadActions() // The same here
You can check if action is enabled to perform action
if action.isEnabled {
// Perform action
}