BBAToolBar.h
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// 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