FUIBannerMessageView
open class FUIBannerMessageView : NibDesignable
FUIBannerMessageView
shows an overlay message centered in the screen underneath a navigation bar, or one of FUIObjectHeader
, FUIProfileHeader
, and FUIKPIHeader
. FUINavigationBar
contains a FUIBannerMessageView
by default.
Call show
function on a FUIBannerMessageView
instance to show the message. By default, the message is shown centered on screen.
Usage
FUINavigationBar
has a FUIBannerMessageView
prepared for you. Usually you don’t need to create an instance of it.
For FUIObjectHeader
, FUIProfileHeader
, and FUIKPIHeader
, however, you need to allocate a FUIBannerMessageView
or its subclasses to the bannerMessage
property of the corresponding header view.
Setup
To display the banner message in a navigation bar, setup a FUINavigationBar
in your navigation controller. You can set either in a nib file or programmatically.
Show message
guard let navBar = self.navigationController?.navigationBar as? FUINavigationBar else {
return
}
navBar.bannerView?.show(message: "This is a test banner", withDuration: 1, animated: true)
/// An example of a UITableViewController with `FUIBannerMessageView` in an `FUIObjectHeader`
class BannerObjectHeaderBannerTVC: UITableViewController {
let objectHeader = FUIObjectHeader()
let bannerView = FUIBannerMessageView()
override func viewDidLoad() {
self.tableView.tableHeaderView = objectHeader
super.viewDidLoad()
bannerView.isFading = false
objectHeader.bannerView = bannerView
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
bannerView.show(message: "200k pending to upload example with text showing wrapping to two lines", withDuration: 5 ,animated: true)
}
// ...
}
Theming
Supported style classes
fdlFUIBannerMessageView
fdlFUIBannerMessageView_titleLabel
fdlFUIBannerMessageView_dividerTop
fdlFUIBannerMessageView_dividerBottom
fdlFUIBannerMessageView_blurView
fdlFUIBannerMessageView_contentView
fdlFUIBannerMessageView_closeImage
-
The content view of
FUIBannerMessageView
instance.Declaration
Swift
@IBOutlet public private(set) var view: UIView!
-
The view which adds blurry effect.
Declaration
Swift
@IBOutlet public private(set) weak var blurView: UIVisualEffectView!
-
The label which contains the message.
Declaration
Swift
@IBOutlet public private(set) var titleLabel: UILabel!
-
The view serves as top divider.
Declaration
Swift
@IBOutlet public private(set) weak var dividerTop: UIView!
-
The view serves as bottom divider.
Declaration
Swift
@IBOutlet public private(set) weak var dividerBottom: UIView!
-
The navigation bar which this
FUIBannerMessageView
instance attacheds to.Declaration
Swift
public weak var navigationBar: UINavigationBar?
-
The header view which this
FUIBannerMessageView
instance attacheds to. It could beFUIObjectHeader
,FUIProfileHeader
, orFUIKPIHeader
.Declaration
Swift
public weak var headerView: UIView?
-
Indicates if to show and dismiss of the view should be fading in or out. The default is true.
Declaration
Swift
public var isFading: Bool
-
The
Close
icon image view. Tap this icon to dismiss thisFUIBannerMessageView
.Declaration
Swift
@IBOutlet public private(set) var closeImage: UIImageView!
-
Show the banner with a message under navigation bar for a certain duration.
Declaration
Swift
open func show(message: String, withDuration duration: TimeInterval = 0, animated: Bool = true)
Parameters
message
The message which will show on the banner.
duration
The duration in seconds for which the message is shown. This message view will be automatically dismissed when the duration is expired. The banner will not be automatically dismissed if the value is smaller or equal to 0. The default is ‘0’, means not to be automatically dismissed.
animated
Whether the banner is shown with an animation. The default is
true
. -
Dismiss the banner.
Declaration
Swift
open func dismissBanner(animated: Bool)
Parameters
animated
Whether the banner should dismiss with an animation.