NatIconButton

public final class NatIconButton : UIView
extension NatIconButton: Pulsable
extension NatIconButton: Badgeable

Note

This component is available in the following variants:
  • ✅ Standard

With the following attribute status:

  • Size:
    • Semi
    • SemiX
    • Medium
  • Icon color:
    • HighEmphasis
    • Primary
    • Light
  • Background style:
    • Inherit
    • Float
    • Overlay
  • ✅ Disabled
  • ✅ Onclick
  • ✅ Icon
  • Interaction state:
    • Enabled
    • Press

NatIconButton is a class that represent the icon button component from the design system. The button colors change according to the current theme configured.

The icon button has two styles, which change the icon color:

  • standardDefault (icon has highEmphasis color)
  • standardPrimary (icon has primary color)
  • standardLight (icon has surface color)

The icon button can have three different sizes (with size semi as default):

  • semi
  • semiX
  • medium > Note: the size can only be changed at init()

Example of usage:

   // An icon with default color and size
   let defaultIconButton = NatIconButton(style: .standardDefault)

   // An icon button with primary color and medium size
   let primaryIconButton = NatIconButton(style: .standardPrimary, size: .medium)

Requires

It’s necessary to configure the Design System with a theme or fatalError will be raised.

   DesignSystem().configure(with: AvailableTheme)
  • State represents state values for NatIconButton component.

    These are all states allowed for a NatIconButton:

    • enabled
    • disabled
    See more

    Declaration

    Swift

    public enum State

Inits

Overrides

  • Undocumented

    Declaration

    Swift

    public override func layoutSubviews()
  • Undocumented

    Declaration

    Swift

    public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
  • Undocumented

    Declaration

    Swift

    public override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)
  • Background represents style values for the NatIconButton component, which apply different colors for the icon.

    These are all the backgrounds allowed for a NatIconButton:

    • inherit (default)
    • float
    • overlay
    See more

    Declaration

    Swift

    public enum Background
  • Sizes is a enum that represents size values for the NatIconButton component.

    These are all sizes allowed for a NatIconButton:

    • semi (default)
    • semiX
    • medium
    See more

    Declaration

    Swift

    public enum Sizes
  • Style represents style values for the NatIconButton component, which apply different colors for the icon.

    These are all styles allowed for a NatIconButton:

    • standardDefault (default: icon has highEmphasis color)
    • standardPrimary (icon has primary color)
    • standardLight (icon has surface color)
    See more

    Declaration

    Swift

    public struct Style

Public methods

  • Undocumented

    Declaration

    Swift

    public func configure(action: @escaping () -> Void)
  • Sets the functionality for the icon button. Example:

    yourIconButton.configure(delegate: self) { (self) in
        // your code for icon button's tap
    }
    

    Declaration

    Swift

    public func configure<Object: AnyObject>(delegate: Object,
                                             action: @escaping (Object) -> Void)

    Parameters

    delegate

    the class that is the delegate for the action (usually, the class itself)

    action

    a block of code to be run when the icon button is pressed

  • Undocumented

    Declaration

    Swift

    public func configure(badgeValue: UInt)
  • Configures a badge to the icon button.

    Example of usage:

    let badge = NatBadge(style: .standard, color: .primary)
    badge.configure(limit: .max99)
    badge.configure(count: 100)
    iconButton.configure(badge: badge)
    

    Declaration

    Swift

    public func configure(badge: NatBadge)

    Parameters

    badge

    A badge from the design system. The badge must be created and configured before setting it to the icon button.

  • Sets the state of the icon button

    Declaration

    Swift

    public func configure(state: State)

    Parameters

    state

    An option from State enum: enabled (default) or disabled

  • Sets an icon for the button view

    Declaration

    Swift

    public func configure(icon: String?)

    Parameters

    icon

    An icon from NatDSIcons, using the function getIcon from NatDSIcons

  • Sets the background style for the icon button

    Declaration

    Swift

    public func configure(background: Background)

    Parameters

    background

    An option from Background enum: inherit (default), float or overlay

  • Sets a style for the component, changing its color

    Declaration

    Swift

    public func configure(style: Style)

    Parameters

    style

    an option from NatIconButton.Style