Skip to content

mercadolibre/MPTopFloatingView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MPTopFloatingView

Use this view to show new activities inside your app. Support iOS 7+.

Example

Demo

Usage

1. Import MPTopFloatingView class

#import <MPTopFloatingView/MPTopFloatingView.h>

2. Create an intance

self.newsView = [[MPTopFloatingView alloc] initTopFloatingViewWithDismissBlock:^(MPTopFloatingViewDismissCause cause) {
    if (cause == MPTopFloatingViewDismissCauseTap) {
        //View was tapped! Use this block to execute something..
    }
}];

Use one of this alternative initializer to customize the view

・More initializers
- (nonnull instancetype)initTopFloatingViewWithText:(nonnull NSString *)text color:(nonnull UIColor *)color icon:(nonnull UIImage *)icon dismissBlock:(MPTopFloatingViewDismissBlock)dismissBlock;
- (nonnull instancetype)initTopFloatingViewWithText:(nonnull NSString *)text color:(nonnull UIColor *)color timeToDismiss:(NSTimeInterval)timeToDismiss dismissBlock:(MPTopFloatingViewDismissBlock)dismissBlock;
- (nonnull instancetype)initTopFloatingViewWithText:(nonnull NSString *)text textFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor color:(nonnull UIColor *)color icon:(nonnull UIImage *)icon finalPosition:(float)finalPosition duration:(float)duration dismissBlock:(MPTopFloatingViewDismissBlock)dismissBlock;
- (nonnull instancetype)initTopFloatingViewWithText:(nonnull NSString *)text textFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor color:(nonnull UIColor *)color icon:(nonnull UIImage *)icon finalPosition:(float)finalPosition duration:(float)duration timeToDismiss:(NSTimeInterval)timeToDismiss dismissBlock:(MPTopFloatingViewDismissBlock)dismissBlock;

3. Include the view inside the hierarchy

[self.view addSubview:newsView];
// Setup contraints...

4. Use this method to start the animation

The parameter is the final state of the view after the animation

[newsView startAnimation:MPTopFloatingViewStatusAppear];

Author

Cristian Gibert