悟空记账

ReverseOrderViewController.m 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // ReverseOrderViewController.m
  3. // Demo-CustomTags
  4. //
  5. // Created by haoyajuan on 2018/2/2.
  6. // Copyright © 2018年 haoyajuan. All rights reserved.
  7. //
  8. #import "ReverseOrderViewController.h"
  9. #import "YJTagsView.h"
  10. @interface ReverseOrderViewController ()
  11. @property (nonatomic,strong) NSArray *tagsArray;
  12. @property (nonatomic,strong) YJTagsView *tagsView;
  13. @property (nonatomic,assign) NSInteger index;
  14. @end
  15. @implementation ReverseOrderViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.view.backgroundColor = [UIColor whiteColor];
  19. self.index = 0;
  20. [self tagview];
  21. UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2.0-40, self.view.frame.size.height-40, 80, 30)];
  22. [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  23. [button setTitle:@"添加待调试" forState:UIControlStateNormal];
  24. [button setBackgroundColor:[UIColor yellowColor]];
  25. [button addTarget:self action:@selector(addTag) forControlEvents:UIControlEventTouchUpInside];
  26. [self.view addSubview:button];
  27. }
  28. - (void)tagview{
  29. self.tagsArray = @[@"全部",@"钢琴",@"吉他",@"电吉他",@"小提琴",@"架子鼓",@"口琴",@"贝斯",@"卡祖笛",@"古筝",@"翻弹",@"音乐",@"指弹",@"千本樱",@"民乐",@"初音MIKU",@"ANIMENZ",@"PENBEAT",@"木吉他",@"二胡",@"COVER",@"交响",@"权御天下",@"普通DISCO",@"OP",@"ILEM",@"原创",@"作业用BGM",@"串烧",@"东方",@"合奏",@"燃向",@"触手",@"试奏",@"ACG指弹",@"武士桑",@"触手猴",@"BGM",@"LAUNCHPAD"];
  30. // 创建标签列表
  31. YJTagsView *tagList = [[YJTagsView alloc] init];
  32. self.tagsView = tagList;
  33. // 高度可以设置为0,会自动跟随标题计算
  34. tagList.frame = CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height - 64);
  35. // 设置排序时,缩放比例
  36. tagList.scaleTagInSort = 1.3;
  37. tagList.tagMargin = 15;
  38. tagList.tagFont = [UIFont systemFontOfSize:20];
  39. // 需要排序
  40. tagList.isSort = YES;
  41. // 标签尺寸
  42. // tagList.tagSize = CGSizeMake(110, 30);
  43. // 不需要自适应标签列表高度
  44. tagList.isFitTagListH = YES;
  45. [self.view addSubview:tagList];
  46. tagList.tagDeleteimage = [UIImage imageNamed:@"close"];
  47. // 设置标签背景色
  48. tagList.tagBackgroundColor = [UIColor yellowColor];
  49. // 设置标签颜色
  50. tagList.tagColor = [UIColor blackColor];
  51. tagList.reverseOrder = YES;
  52. // 点击标签,就会调用,点击标签,删除标签
  53. __weak typeof(tagList) weakTagList = tagList;
  54. tagList.clickTagBlock = ^(NSString *tag){
  55. [weakTagList dragViewfrom:tag.integerValue to:0];
  56. };
  57. tagList.clickDeleteBlock = ^(NSString *tag){
  58. [weakTagList deleteTag:tag];
  59. };
  60. }
  61. - (void)addTag{
  62. // NSString *tagStr = [NSString stringWithFormat:@"%@ (%d)",self.tagsArray[arc4random_uniform(3)],index];
  63. NSString *tagStr = [NSString stringWithFormat:@"%@",self.tagsArray[arc4random_uniform(self.tagsArray.count-1)]];
  64. self.index++;
  65. // [self.tagsView addSingleTag:tagStr];
  66. [self.tagsView addTag:tagStr];
  67. }
  68. @end