iOS easy-to-use label list interface

Source: Internet
Author: User

iOS easy-to-use label list interface Demo Effect:

Demo Demos:
  • 1. Use the cocoapods ingest Yztaglistview or drag the folder directly into the YZTagListView project

  • 2. Import the YZTagListView.h header file

    1 #import "YZTagList.h"
  • 3. Create a Yztaglistview control

    123   YZTagList *tagList = [[YZTagList alloc] init];  tagList.backgroundColor = [UIColor brownColor];  _tagList = tagList;
  • 4. Set the Yztaglistview property (optional)

    12345   // 高度可以设置为0,会自动跟随标题计算  tagList.frame = CGRectMake(0, 64, self.view.bounds.size.width, 0);  // 设置标签背景色  tagList.tagBackgroundColor = [UIColor colorWithRed:20 / 255.0 green:160 / 255.0 blue:250 / 255.0 alpha:1];  // 设置标签颜色  tagList.tagColor = [UIColor whiteColor];  // 设置标签删除图片  tagList.tagDeleteimage = [UIImage imageNamed:@"chose_tag_close_icon"];
  • 5. Add tags

12345 /** *  添加标签 * *  @param tagStr 标签文字 */- (void)addTag:(NSString *)tagStr;
    • 6. Add Multiple tags

12345 /** *  添加多个标签 * *  @param tagStrs 标签数组,数组存放(NSString *) */- (void)addTags:(NSArray *)tagStrs;
    • 7. Delete tags

12345 /** *  删除标签 * *  @param tagStr 标签文字 */- (void)deleteTag:(NSString *)tagStr;
    • 8. Click on the Monitor tab

123456789 /** *  点击标签,执行Block */@property (nonatomic, strong) void(^clickTagBlock)(NSString *tag);列如:点击标签,删除标签  // 点击标签,就会调用    __weak typeof(_tagList) weakTagList = _tagList;    _tagList.clickTagBlock = ^(NSString *tag){        [weakTagList deleteTag:tag];    };
    • 9. Sorting function

12345 属性:/** *  是否需要排序功能 */@property (nonatomic, assign) BOOLisSort;/** *  在排序的时候,放大标签的比例,必须大于1 */@property (nonatomic, assign) CGFloat scaleTagInSort;
123456789101112131415161718 实例:- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view.    NSArray *tags = @[@"小码哥",@"小码哥1",@"小码哥2",@"小码哥3",@"iOS学院",@"iOS学院1",@"iOS学院2",@"iOS学院3",@"吖了个峥",@"吖了个峥1",@"吖了个峥2",@"吖了个峥3"];    // 创建标签列表    YZTagList *tagList = [[YZTagList alloc] init];    // 高度可以设置为0,会自动跟随标题计算    tagList.frame = CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height - 64);    // 设置排序时,缩放比例    tagList.scaleTagInSort = 1.3;    // 需要排序    tagList.isSort = YES;    // 标签尺寸    tagList.tagSize = CGSizeMake(80, 30);    // 不需要自适应标签列表高度    tagList.isFitTagListH = NO;    [self.view addSubview:tagList];    // 设置标签背景色    tagList.tagBackgroundColor = [UIColor colorWithRed:20 / 255.0 green:160 / 255.0 blue:250 / 255.0 alpha:1];    // 设置标签颜色    tagList.tagColor = [UIColor whiteColor];    /**     *  这里一定先设置标签列表属性,然后最后去添加标签     */    [tagList addTags:tags];}

 

iOS easy-to-use label list interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.