BBAToolBar.h 2.54 KB
//
//  BBAToolBar.h
//  BBAPods
//
//  Created by liuboyang01 on 16/8/17.
//  Copyright © 2016年 Baidu. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "BBAToolBarItem.h"

/*
 BBAToolBarBackgroundStyle
 背景
 */
typedef enum
{
    BBAToolBarBackgroundStyleDefault = 1,
    BBAToolBarBackgroundStyleBlack,
    BBAToolBarBackgroundStyleLightTranslucent,
    BBAToolBarBackgroundStyleTranslucent
}BBAToolBarBackgroundStyle;

@protocol BBAToolBarProtocol <NSObject>

- (void)toolBarFrameDidChanged:(CGRect)lastFrame
                  changedFrame:(CGRect)changedFrame;

@end

/*
 BBAToolBarBackgroundStyle变化通知,这里的item只是自定义的非系统的显示类型
 */
typedef void(^BBAToolBarBackgroundStyleChangedBlock)(BBAToolBarItem *item,BBAToolBarBackgroundStyle toolBarBackgroundType);

@interface BBAToolBar : UIView

@property (nonatomic,assign) BBAToolBarBackgroundStyle toolBarBackgroundStyle;
@property (nonatomic,copy)   BBAToolBarBackgroundStyleChangedBlock toolBarBackgroundStyleChangedBlock;
@property (nonatomic,strong,readonly) NSArray *toolBarItems;
@property (nonatomic,assign) BOOL alwaysTopView;
@property (nonatomic,weak) id<BBAToolBarProtocol> toolBarDelegate;
@property (nonatomic, assign) CGRect extraHitRegion;
@property (nonatomic, assign) BOOL isInBrowserFrame;//toolbar是否在搜索浏览框架,为了解决浏览框架看视频横屏退后台再返回toolbar错乱
@property (nonatomic, assign) BOOL autoAdjustFrame; // 是否自动调整Frame,默认YES
@property (nonatomic, assign, getter=isSeparatorHidden) BOOL separatorHidden;  // 是否隐藏分隔线

- (void)setToolBarItems:(NSArray *)toolBarItems
			   animated:(BOOL)animated;
/*
 遍历每个item view的frame
 */
- (void)enumerateItemsFrames:(NSArray *)toolBarItems
				  usingBlock:(void(^)(BBAToolBarItem *item,CGRect frame,BOOL *stop))block;
- (void)getItemFrameByID:(NSUInteger)itemID
             complection:(void(^)(CGRect frame,BOOL hasFound))block;

/*
 以下几个函数,仅支持系统自带itemID,且不能是BBAToolBarSystemItemIDFlexibleSpace或BBAToolBarSystemItemIDFixedSpace
 如果toolBarItems中有多个相同itemID,则第一个有效
 */
// 用新item替换旧的item,newItem为新的item,oldItemID为被替换掉的itemID,新的item组件frame被设置成和旧的item一样
- (BOOL)replaceWithItem:(BBAToolBarItem*)newItem
         replacedItemID:(NSUInteger)oldItemID;
// 替换某一个item的事件
- (BOOL)setTarget:(id)target
           action:(SEL)action
       withItemID:(NSInteger)itemID;

- (BBAToolBarItem *)itemWithID:(NSInteger)itemID;

@end