Coder Social home page Coder Social logo

afminfobanner's Introduction

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 7 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'

Contact person

Romans Karpelcevs, [email protected]

License

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

afminfobanner's People

Contributors

alesker avatar karpelcevs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.