Latest 0.0.1
Homepage https://github.com/xx-li/QFToolBar
License MIT
Platforms ios 6.0, requires ARC
Dependencies LXLayoutButton
Frameworks Foundation, CoreGraphics, UIKit
Authors

LXToolBar

使用AutoLayout实现的工具条,比较适合用于自定义Tabbar、下拉选择Bar等。
等比例布局它上面的各个Item,并支持AutoLayout。

图示如下:

QFToolBar

CocoaPods接入

pod 'LXToolBar', '~> 0.2'

使用方法

#pragma mark - LXToolBarDelegate
//Item数量
- (NSInteger)numberOfItemsInToolBar:(LXToolBar *)toolBar {

    return _itemNames.count;
}

//创建每个Item
- (UIControl *)toolBar:(LXToolBar *)toolBar itemForIndex:(NSInteger)index {

    LXLayoutButton * button = [LXLayoutButton buttonWithType:UIButtonTypeCustom];
    button.subMargin = 5.0;
    button.layoutButtonType = LXLayoutButtonTypeRight;
     forState:UIControlStateNormal];
     forState:UIControlStateSelected];
     forState:UIControlStateNormal];
     forState:UIControlStateSelected];
     forState:UIControlStateNormal];

    return button;
}

//创建一个贴着ToolBar底部,点击后会滑动的滑块
- (UIView *)selectedTagViewForToolBar:(LXToolBar *)toolBar {
    //通过Frame可以设定此View的大小
    CGFloat widht = CGRectGetWidth([UIScreen mainScreen].bounds) / _itemNames.count - 5;
    UIView * tagView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, widht, 3)];
    tagView.backgroundColor = [UIColor orangeColor];
    return tagView;
}

//选中Item执行的回调
- (void) toolBar:(LXToolBar *)toolBar didSelectItemAtIndex:(NSInteger)currentIndex previousSeleectedItemIndex:(NSInteger)previousIndex {
    NSLog(@"currentIndex %@  previousIndex %@", @(currentIndex), @(previousIndex));
    _label.text = _itemNames[currentIndex];
}

提供的接口

@property (weak, nonatomic) IBOutlet id <LXToolBarDelegate> delegate;

/*! 画一根下部的分割线,若设为Yes,则会将isDrawTopSepLine设为NO */
@property (assign, nonatomic) BOOL isDrawBottomSepLine;

/*! 画一根上部的分割线若设为Yes,则会将isDrawBottomSepLine设为NO */
@property (assign, nonatomic) BOOL isDrawTopSepLine;

/*! 是否显示每个item之间的分割线 */
@property (assign, nonatomic) BOOL isShowSeparatorLine;

/*! 是否隐藏滑块 */
@property (assign, nonatomic) BOOL isShowSelectedTag;

/*! 分割线的EdgeInsets,只有上下的值会生效 */
@property (assign, nonatomic) UIEdgeInsets separatorLineInsets;
@property (strong, nonatomic) UIColor *separatorLineColor;
@property (strong, nonatomic) UIImage *separatorImage;

/*! 选中的下标 */
@property (assign, nonatomic) NSInteger selectedIndex;

/*! 隐藏当前选中状态 */
- (void) hiddenCurrentSelectedStatus;

/*! 重新加载所有的Items */
- (void) reloadAllItems;

接口使用:

- (IBAction)buttonClick:(id)sender {
    //隐藏ToolBar的选中状态
    [_toolBar hiddenCurrentSelectedStatus];
}

- (IBAction)isShowSelectedTagSwitchValueChanged:(id)sender {
    UISwitch * curSwitch = (UISwitch *)sender;
    _toolBar.isShowSelectedTag = curSwitch.isOn;
    [_toolBar reloadAllItems];
}

- (IBAction)isShowItemsSeparatorLineSwitchValueChanged:(id)sender {
    UISwitch * curSwitch = (UISwitch *)sender;
    _toolBar.isShowSeparatorLine = curSwitch.isOn;
    [_toolBar reloadAllItems];
}

Latest podspec

{
    "name": "QFToolBar",
    "version": "0.0.1",
    "summary": "u5b9au5236u7684u5de5u5177u6761uff0cu7c7bu4f3cUITabBaruff0cu4f7fu7528AutoLayoutu6280u672fuff0cu652fu6301u6a2au7ad6u5c4fu5207u6362",
    "homepage": "https://github.com/xx-li/QFToolBar",
    "license": "MIT",
    "authors": {
        "xx-li": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/xx-li/QFToolBar.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "QFToolBar/*",
        "QFToolBar/**/*.{h,m}"
    ],
    "exclude_files": "QFToolBarDemo",
    "frameworks": [
        "Foundation",
        "CoreGraphics",
        "UIKit"
    ],
    "requires_arc": true,
    "dependencies": {
        "LXLayoutButton": [
            "~> 0.0.1"
        ]
    }
}

Pin It on Pinterest

Share This