• This repository has been archived on 28/Feb/2019
  • Stars
    star
    165
  • Rank 228,906 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy to use auto-hiding notice bar below Navigation Bar

AFMInfoBanner

CI Status Version License Platform

AFMInfoBanner can be used to unobtrusively notify users about successful or erroneous events which do not require any specific action or UI locking. Good examples are network errors on the screens which can be functional even without the data that failed.

Default error case looks like this:

Animated Example

View is trying to find a navigation bar and show itself beneath it. If that fails, it shows from top of the window, adjusting height to be below status bar. View is resized to any text, but auto-hiding interval makes long text hard to read, so it's better to keep it short.

Background and text colours, as well as font are customisable through UIAppearance.

Usage

There are two styles: AFMInfoBannerStyleError for error messages and AFMInfoBannerStyleInfo for other, like info or success notices. By default error is red and info is green.

Easiest way to use it is calling a class method passing text and kind of message:

[AFMInfoBanner showAndHideWithText:@"Error text" style:AFMInfoBannerStyleError];

If you need another hiding interval, you can pass it like this:

[AFMInfoBanner showWithText:@"Error text" style:AFMInfoBannerStyleError andHideAfter:1.0];

If you want to create or show it yourself, as well as have a overriding point in case of inheritance, there are -show: and -hide: methods available.

If you need to hide any possibly showing banner, use +[AFMInfoBanner hideAll]. Possible case for this is navigating away from the page. Without this banner is going to stay visible during navigation because it is attached to navigation bar's view.

You can use Example project to play around with AFMInfoBanner. To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

iOS 8 and up.

Usage of UINavigationBar or UINavigationController for navigation bar.

Algorithm uses view controller hierarchy (CVKHierarchySearcher) to find navigation bar on the topmost view controller. First it checks the topmost controller's first level of subviews for UINavigationBar. If this fails, searches for topmost available UINavigationController. If that fails as well, shows from the status bar. Because of this logic, might work strangely with custom navigation bar replacements.

Installation

AFMInfoBanner is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AFMInfoBanner'

License

AFMInfoBanner is available under the MIT license. See the LICENSE file for more info.