GithubHelp home page GithubHelp logo

taglist's Introduction

TagList

自定义标签显示控件,简单灵活易用,功能点如下:
1:可动态 添加/删除 一个或多个 标签
2:根据当前tag内容多少进行自动排列
3:支持自动换行及添加多个标签后的整体自动布局(整体自动布局可开启关闭)
4:可自定义tag文本字体大小、字体颜色、背景颜色、边框颜色及宽度
5:每项tag标签点击均可触发自定义事件

####效果图如下

image

####使用方法 首先把TagViewList文件夹拖到您的项目中

#import "ViewController.h"
#import "ZLTagListView.h"

#define kMainScreenWidth [[UIScreen mainScreen] bounds].size.width
#define kMainScreenHeight [[UIScreen mainScreen] bounds].size.height

@interface ViewController () <UITextFieldDelegate>
{
    IBOutlet UITextField *_textField;
    //创建ZLTagListView对象
    ZLTagListView *_tagListView;
}
@end

- (void)createTagListView
{
    //初始坐标
    _tagListView = [[ZLTagListView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth - 40, 10) tagTitles:@"Foo,Tag Label 1,Tag Label 2"];
    _tagListView.center = self.view.center;
    //自定义tag背景色
    _tagListView.tagBgColor = [UIColor colorWithRed:0.18 green:0.64 blue:0.37 alpha:1];
    //自定义tag边框颜色
    _tagListView.tagBorderColor = [UIColor darkGrayColor];
    //自定义tag边框宽度
    _tagListView.tagBorderWidth = 1.0f;
    //自定义tag标题颜色
    _tagListView.tagTitleColor = [UIColor whiteColor];
    //自定义tag字体大小
    _tagListView.tagFontSize = 15.0f;
    //设置是否需要重新布局
    _tagListView.isNeedLayoutSubViews = YES;//default is Yes
    
    typeof(ViewController) *weakSelf = self;
    //实现点击方法
    [_tagListView setClickAction:^(NSString *title) {
        [weakSelf showAlertView:[NSString stringWithFormat:@"click %@", title]];
    }];
    
    [self.view addSubview:_tagListView];
}

####添加一个或者多个标签

- (IBAction)btnClick:(id)sender
{
    //多个标签的则需要以中文或者英文状态下的逗号进行分隔
    [_tagListView addTagTitle:@"new tag"];
}

####删除一个或者多个标签

- (IBAction)btnDelete:(id)sender
{
    //多个标签的则需要以中文或者英文状态下的逗号进行分隔
    [_tagListView deleteTagTitle:@"Foo"];
}

taglist's People

Contributors

longitachi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.