最近直播很火,尤以映客为甚,所以仿照映客,造了一个顶部toast提示的小轮子,支持队列显示。
开放除了这些接口,如果不够需要的话可以自己再加一些设置:
+ (void)showToptoastWithText:(NSString *)text;
+ (void)showToptoastWithText:(NSString *)text duration:(CGFloat)duration;
+ (void)showToptoastWithText:(NSString *)text duration:(CGFloat)duration height:(float)height;
+ (void)showToptoastWithText:(NSString *)text duration:(CGFloat)duration height:(float)height backGroundColor:(UIColor *)color;
+ (void)showToptoastWithText:(NSString *)text duration:(CGFloat)duration height:(float)height backGroundColor:(UIColor *)color alpha:(float)alpha;
一些宏定义:
//默认停留时间
#define ToastDispalyDuration 2.0f
//默认背景色
#define ToastBackgroundColor [UIColor purpleColor]
//默认高度
#define ToastHeight 64
一些属性:
@property (nonatomic, strong) UIButton *contentView;
@property (nonatomic, assign) CGFloat duration;
@property (nonatomic, assign) CGFloat height;
@implementation中代码:
//多次