FUIActivityControl
open class FUIActivityControl : NibDesignable, FUIBackgroundSchemeSupporting
FUIActivityControl
is a stand-alone component supporting user activities. By default, it supports phone, email, message, videoCall. FUIContactCell
embed with a FUIActivityControl
by default.
Code usage:
//You can create your own activity object if you want.
let myCustomActivity = FUIActivityItem(icon: UIImage(named: "asset"), identifier: "mycustomer.twilio")
let activities: [FUIActivityItem] = [FUIActivityItem.phone, FUIActivityItem.message, myCustomActivity]
//Create a FUIActivityControl object.
let activityControl = FUIActivityControl()
activityControl.addActivities(activities)
activityControl.delegate = self
//Optionally, set an item size (if nil, intrinsic size of image will be used)
activityControl.itemSize = CGSize(width: 44.0, height: 44.0)
//Optionally, set a limit to visible items (useful for hiding items in `.compact` horizontal mode)
activityControl.maxVisibleItems = 3
//Optionally, set the inter-item spacing (useful for showing more items in `.compact` horizontal mode)
activityControl.spacing = 10.0
//Implement this method in your class to handle action.
func activityControl(_ activityControl: FUIActivityControl, didSelectActivity activityItem: FUIActivityItem) {
switch activityItem {
case FUIActivityItem.phone:
//do something
case FUIActivityItem.message:
//do something
case myCustomActivity:
//do something
default:
break
}
}
## Attention
The delegate object with type FUIActivityControlDelegate
is declared as a weak reference. So on deallocation it will be automatically set to nil. To keep it alive as expected, developer should retain the delegate object during its whole execution scope.
-
A dictionary stores pairs of
FUIActivityItem
and its correspondingUIButtom
.Declaration
Swift
public var activityItems: [FUIActivityItem : FUIButton]
-
The object acts as the delegate of
FUIActivityControl
.Declaration
Swift
public weak var delegate: FUIActivityControlDelegate?
-
Limits on visible items in activity control.
Declaration
Swift
public var maxVisibleItems: Int { get set }
-
Optional value, to constrain all items in the
FUIActivityControl
to a single size.Declaration
Swift
public var itemSize: CGSize? { get set }
-
Inter-item spacing between items in control. Follows behavior of
UIStackView.spacing
property. Defaults to 10.0.Declaration
Swift
public var spacing: CGFloat { get set }
-
Describes whether the view’s background color is
light
(e.g. white, or other light color) ordark
(black, dark blue, etc.). If view’s background color isclear
, should describe the ‘effective’ background color from backing views. default:.light
Declaration
Swift
public var backgroundColorScheme: FUIBackgroundColorScheme { get set }
-
Add an activity button into FUIActivityControl component.
Declaration
Swift
public func addActivity(_ activity: FUIActivityItem)
Parameters
activity
The activity to be added to activity control.
-
Add a set of activity buttons into FUIActivityControl component.
Declaration
Swift
public func addActivities(_ activities: [FUIActivityItem])
Parameters
activities
The activities to be added to activity control.