FUIActivityControl

open class FUIActivityControl: NibDesignable

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 = 29.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 } }

  • A dictionary stores pairs of FUIActivityItem and its corresponding UIButtom.

    Declaration

    Swift

    open var activityItems = [FUIActivityItem : UIButton]()
  • The object acts as the delegate of FUIActivityControl.

    Declaration

    Swift

    open weak var delegate: FUIActivityControlDelegate?
  • Limits on visible items in activity control.

    Declaration

    Swift

    open var maxVisibleItems: Int = 1000
  • Optional value, to constrain all items in the FUIActivityControl to a single size.

    Declaration

    Swift

    open var itemSize: CGSize? = nil
  • Inter-item spacing between items in control. Follows behavior of UIStackView.spacing property. Defaults to 29.0.

    Declaration

    Swift

    open var spacing: CGFloat = 29.0
  • Add an activity button into FUIActivityControl component.

    Declaration

    Swift

    open 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

    open func addActivities(_ activities: [FUIActivityItem])

    Parameters

    activities

    The activities to be added to activity control.