BBAMultiTabBarButtonItem.h 3.09 KB
//
//  BBAMultiTabBarButtonItem.h
//  BBAUIKit
//
//  Created by liyongrui on 2018/12/14.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <BBAUIKit/BBABadgeValueView.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, BBAMultiTabBarButtonItemStyle) {
    BBAMultiTabBarButtonItemStyleText,
    BBAMultiTabBarButtonItemStyleImage,
    BBAMultiTabBarButtonItemStyleSwitch,
    BBAMultiTabBarButtonItemStyleCustom,
};

@class BBAMultiTabBarButtonItem;
@protocol BBAMultiTabBarButtonItemDelegate<NSObject>
- (void)multiTabBarButtonItemDidClick:(BBAMultiTabBarButtonItem *)item;
@end

/**********************************************************************
 *                  BBAMultiTabBarButtonItem
 **********************************************************************/

@interface BBAMultiTabBarButtonItem: NSObject
@property (nonatomic, assign, getter=isSelected) BOOL selected;
@property (nonatomic, assign) CGPoint offset;
@property (nonatomic, assign) CGPoint badgeOffset;
@property (nonatomic, assign) CGFloat badgeAlpha;
@property (nonatomic, strong) UIView *customView;
@property (nonatomic, assign) CGSize customSize;
@property (nonatomic, assign) BOOL separatorLineHidden;//右边button是否要隐藏分割线

/// 按钮点击热区的位置大小,是相对于BBAMultiTabBar(仅在添加至Bar上之后有效)
@property (nonatomic, assign, readonly) CGRect hitRect;

@property (nonatomic, weak) id<BBAMultiTabBarButtonItemDelegate> delegate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) UIImage *normalImage;
@property (nonatomic, strong) UIImage *selectedImage;
@property (nonatomic, strong) UIImage *backgroundImage;
@property (nonatomic, assign) BBAMultiTabBarButtonItemStyle style;
@property (nonatomic, strong) UIButton *view;
@property (nonatomic, strong) BBABadgeValueView *badgeView;
@property (nonatomic, weak) id target;
@property (nonatomic, assign) SEL action;
@property (nonatomic, assign) CGRect viewFrame;

- (instancetype)initWithTitle:(NSString *)title;
- (instancetype)initWithTitle:(NSString *)title target:(id)target action:(SEL)action;

- (instancetype)initWithImage:(UIImage *)image;
- (instancetype)initWithImage:(UIImage *)image target:(id)target action:(SEL)action;

- (instancetype)initWithBackgroundImage:(UIImage *)backgroundImage normalImage:(UIImage *)normalImage selectedImage:(UIImage *)selectedImage;

- (void)setImage:(UIImage *)image forState:(UIControlState)state;

- (instancetype)initWithCustomView:(UIView *)customView;
- (instancetype)initWithCustomView:(UIView *)customView target:(id)target action:(SEL)action;

- (void)showBadge;
- (void)showBadgeText:(NSString *)text;
- (void)clearBadge;

#ifdef DEBUG
- (void)setAccessibility;
#endif

- (void)updateBadgePosition;

- (void)setBackgroundImage:(UIImage *)dstImage srcImage:(UIImage *)srcImage progress:(CGFloat)progress;
- (void)setNormalImage:(UIImage *)dstImage srcImage:(UIImage *)srcImage progress:(CGFloat)progress;
- (void)setSelectedImage:(UIImage *)dstImage srcImage:(UIImage *)srcImage progress:(CGFloat)progress;

@end

NS_ASSUME_NONNULL_END