├── CLTageViewDemo ├── ViewController.h ├── AppDelegate.h ├── main.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── AppDelegate.m └── ViewController.m ├── .gitignore ├── CLTagView ├── View │ ├── CLTagView.h │ ├── CLRecentTagView.h │ ├── CLDispalyTagView.h │ ├── CLTagButton.h │ ├── CLRecentTagView.m │ ├── CLTagView.m │ ├── CLTagButton.m │ └── CLDispalyTagView.m ├── Model │ ├── CLTagsModel.h │ └── CLTagsModel.m ├── tools │ ├── CLTools.m │ └── CLTools.h └── Controller │ ├── CLTagViewController.h │ └── CLTagViewController.m ├── CLTagView.podspec ├── CLTageViewDemoTests └── CLTageViewDemoTests.m ├── LICENSE ├── CLTageViewDemoUITests └── CLTageViewDemoUITests.m ├── README.md └── CLTageViewDemo.xcodeproj └── project.pbxproj /CLTageViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | 19 | #CocoaPods 20 | Pods 21 | -------------------------------------------------------------------------------- /CLTageViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CLTageViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CLTagView/View/CLTagView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagView.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/25. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CLTagsModel; 11 | 12 | @interface CLTagView : UIView 13 | 14 | @property (strong, nonatomic) CLTagsModel *tags; 15 | 16 | /** 17 | 用于高亮最近标签页中相同的标签 18 | */ 19 | @property (strong, nonatomic) NSArray *displayTags; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /CLTagView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "CLTagView" 4 | s.version = "1.0.0" 5 | s.summary = "An easy way to create a tag view like WeChat" 6 | s.homepage = "https://github.com/VamCriss/CLTagView" 7 | s.license = 'MIT' 8 | s.author = { "criss" => "ericluo0114@hotmail.com" } 9 | s.platform = :ios, "8.0" 10 | s.source = { :git => "https://github.com/VamCriss/CLTagView.git", :tag => s.version } 11 | s.source_files = 'CLTagView/**/*.{h,m}' 12 | s.requires_arc = true 13 | 14 | end 15 | -------------------------------------------------------------------------------- /CLTagView/Model/CLTagsModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagsModel.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/26. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CLTagButton; 11 | 12 | @interface CLTagsModel : NSObject 13 | 14 | @property (copy, nonatomic) NSString *title; 15 | @property (strong, nonatomic) NSArray *tagsArray; 16 | 17 | /** 18 | 根据标签文字内容生成的标签按钮 19 | */ 20 | @property (strong, nonatomic, readonly) NSArray *tagBtnArray; 21 | 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /CLTagView/View/CLRecentTagView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CLRecentTagView.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CLTagsModel; 11 | 12 | @interface CLRecentTagView : UIView 13 | 14 | /** 15 | 用于高亮最近标签页中相同的标签(要高亮的话,需先给displayTags赋值,再赋值tagsModel) 16 | */ 17 | @property (strong, nonatomic) NSArray *displayTags; 18 | 19 | /** 20 | 最近标签页中显示的标签 21 | */ 22 | @property (strong, nonatomic) NSArray *tagsModel; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /CLTagView/View/CLDispalyTagView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CLDispalyTagView.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CLDispalyTagView : UIScrollView 12 | 13 | - (instancetype)initWithOriginalY:(CGFloat)originalY Font:(CGFloat)fontSize; 14 | 15 | /** 16 | 设置输入框中输入时标签的文字颜色(默认黑色) 17 | */ 18 | @property (strong, nonatomic) UIColor *normalTextColor; 19 | 20 | /** 21 | 设置输入框中输入时标签的边框颜色(默认灰色) 22 | */ 23 | @property (strong, nonatomic) UIColor *textFieldBorderColor; 24 | 25 | /** 26 | 限制单个标签最大输入的字符个数(默认是10) 27 | */ 28 | @property (assign, nonatomic) NSInteger maxStringAmount; 29 | 30 | /** 31 | 最多显示标签的行数(默认是3) 32 | */ 33 | @property (assign, nonatomic) NSInteger maxRows; 34 | 35 | /** 36 | 显示已经被打上的标签,如果不想显示传递nil 37 | */ 38 | @property (strong, nonatomic) NSArray *labels; 39 | 40 | /** 41 | 获取贴上的标签 42 | */ 43 | @property (strong, nonatomic, readonly) NSArray *tags; 44 | 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /CLTagView/tools/CLTools.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLTools.m 3 | // CLTageViewDemo 4 | // 5 | // Created by 邢媛媛 on 2017/4/25. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "CLTools.h" 10 | 11 | NSString *const kCLRecentTagViewTagClickNotification = @"kCLRecentTagViewTagClickNotification"; 12 | NSString *const kCLRecentTagViewTagClickKey = @"kCLRecentTagViewTagClickKey"; 13 | 14 | NSString *const kCLTagViewTagDeleteNotification = @"kCLTagViewTagDeleteNotification"; 15 | NSString *const kCLTagViewTagDeleteKey = @"kCLTagViewTagDeleteKey"; 16 | 17 | NSString *const kCLDisplayTagViewAddTagNotification = @"kCLDisplayTagViewAddTagNotification"; 18 | NSString *const kCLDisplayTagViewAddTagKey = @"kCLDisplayTagViewAddTagKey"; 19 | NSString *const kCLDisplayTagViewAddTagObject = @"kCLDisplayTagViewAddTagObject"; 20 | 21 | @implementation CLTools 22 | 23 | + (instancetype)sharedTools { 24 | static CLTools *instance; 25 | static dispatch_once_t onceToken; 26 | dispatch_once(&onceToken, ^{ 27 | instance = [[self alloc] init]; 28 | }); 29 | return instance; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /CLTageViewDemoTests/CLTageViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLTageViewDemoTests.m 3 | // CLTageViewDemoTests 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CLTageViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CLTageViewDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CLTagView/View/CLTagButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagButton.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/21. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CLTagButton; 11 | @protocol CLTagButtonDelegate 12 | 13 | @optional 14 | 15 | // 菜单栏删除按钮回调 16 | - (void)tagButtonDelete:(CLTagButton *)tagBtn; 17 | 18 | // 展示标签页displayTagView 上的标签点击事件(状态变化已经在内部处理) 19 | - (void)tagButtonDidSelected:(CLTagButton *)tagBtn; 20 | 21 | // 最近标签页resentTagView 上的标签点击事件 22 | - (void)recentTagButtonClick:(CLTagButton *)tagBtn; 23 | 24 | @end 25 | 26 | @interface CLTagButton : UIButton 27 | 28 | // 初始化标签展示页的标签(上半部分标签) 29 | - (instancetype)initWithTextField:(UITextField *)textField; 30 | 31 | // 初始化最近标签页的标签(下半部分标签) 32 | + (instancetype)initWithTagDesc:(NSString *)tagStr; 33 | 34 | @property (weak, nonatomic) id tagBtnDelegate; 35 | 36 | /** 37 | 最近标签展示页的标签是否被选中 38 | */ 39 | @property (assign, nonatomic) BOOL tagSelected; 40 | 41 | /** 42 | 判断标签展示页中前后两次点击的标签是否为自己,用于“删除菜单栏的显示与否” 43 | */ 44 | @property (assign, nonatomic) BOOL isNotSelf; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 灬Criss丶祢 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /CLTageViewDemoUITests/CLTageViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLTageViewDemoUITests.m 3 | // CLTageViewDemoUITests 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CLTageViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation CLTageViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /CLTageViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /CLTagView/Controller/CLTagViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagViewController.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CLTagsModel; 11 | @class CLTagViewController; 12 | @protocol CLTagViewControllerDelegate 13 | 14 | /** 15 | 返回标签展示页的所有标签(默认是点击保存按钮) 16 | @param tags 标签 17 | */ 18 | - (void)tagViewController:(CLTagViewController *)tagController tags:(NSArray *)tags; 19 | 20 | @end 21 | 22 | @interface CLTagViewController : UIViewController 23 | 24 | @property (weak, nonatomic) id tagsDelegate; 25 | 26 | /** 27 | 标签展示页默认显示标签 28 | */ 29 | @property (nonatomic, strong) NSArray *tagsDisplayArray; 30 | 31 | /** 32 | 最近标签页默认显示的标签 33 | */ 34 | @property (nonatomic, strong) NSArray *tagsModelArray; 35 | 36 | /** 37 | 最近标签页是否高亮展示页中相同的标签 38 | */ 39 | @property (assign, nonatomic, getter=isHighlightTag) BOOL highlightTag; 40 | 41 | /** 42 | 设置标签的圆角(不设置值则默认是控件高度的一半) 43 | */ 44 | @property (assign, nonatomic) CGFloat cornerRadius; 45 | 46 | /** 47 | 设置输入框中输入时标签的文字颜色(默认黑色) 48 | */ 49 | @property (strong, nonatomic) UIColor *normalTextColor; 50 | 51 | /** 52 | 设置输入框中输入时标签的边框颜色(默认灰色) 53 | */ 54 | @property (strong, nonatomic) UIColor *textFieldBorderColor; 55 | 56 | /** 57 | 限制单个标签最大输入的字符个数(默认是10) 58 | */ 59 | @property (assign, nonatomic) NSInteger maxStringAmount; 60 | 61 | /** 62 | 最多显示标签的行数(默认是3) 63 | */ 64 | @property (assign, nonatomic) NSInteger maxRows; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /CLTageViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /CLTagView/Model/CLTagsModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagsModel.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/26. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "CLTagsModel.h" 10 | #import "CLTagButton.h" 11 | #import "CLTools.h" 12 | 13 | @implementation CLTagsModel 14 | 15 | - (void)setTagsArray:(NSArray *)tagsArray { 16 | _tagsArray = tagsArray; 17 | NSMutableArray *tagBtnArrayM = [NSMutableArray array]; 18 | for (int i = 0; i < _tagsArray.count; i ++) { 19 | CLTagButton *preTagBtn; 20 | CLTagButton *currentTagBtn; 21 | preTagBtn = i?tagBtnArrayM[i - 1]: nil; 22 | currentTagBtn = [CLTagButton initWithTagDesc:_tagsArray[i]]; 23 | [tagBtnArrayM addObject: (CLTagButton *)[self reloadTagViewPreTag:preTagBtn currentTagBtn:currentTagBtn]]; 24 | } 25 | _tagBtnArray = tagBtnArrayM.copy; 26 | } 27 | 28 | - (UIView *)reloadTagViewPreTag:(UIView *)preTagBtn currentTagBtn:(UIView *)currentTagBtn { 29 | 30 | CGFloat preTaling = preTagBtn? CGRectGetMaxX(preTagBtn.frame) : 0; 31 | CGFloat preBottom = preTagBtn? CGRectGetMaxY(preTagBtn.frame) : 0; 32 | CGFloat preY = preTagBtn? preTagBtn.frame.origin.y : kCLDistance; 33 | 34 | if (preTaling + kCLTagViewHorizontaGap * 2 + currentTagBtn.bounds.size.width > [UIScreen mainScreen].bounds.size.width) { 35 | currentTagBtn.frame = CGRectMake(kCLTagViewHorizontaGap, preBottom + kCLTextFieldsVerticalGap, currentTagBtn.frame.size.width, currentTagBtn.frame.size.height); 36 | }else { 37 | currentTagBtn.frame = CGRectMake(preTaling + kCLTextFieldsHorizontalGap, preY, currentTagBtn.frame.size.width, currentTagBtn.frame.size.height); 38 | } 39 | return currentTagBtn; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /CLTageViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /CLTagView/View/CLRecentTagView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLRecentTagView.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "CLRecentTagView.h" 10 | #import "CLTagView.h" 11 | #import "CLTools.h" 12 | #import "CLTagsModel.h" 13 | #import "CLTagButton.h" 14 | 15 | @interface CLRecentTagView () 16 | 17 | @property (nonatomic, weak) UIScrollView *scrollView; 18 | 19 | @end 20 | 21 | @implementation CLRecentTagView 22 | 23 | - (instancetype)initWithFrame:(CGRect)frame { 24 | if (self = [super initWithFrame:frame]) { 25 | [self showUI]; 26 | } 27 | return self; 28 | } 29 | 30 | - (void)showUI { 31 | self.backgroundColor = cl_colorWithHex(0xf0eff3); 32 | 33 | UIScrollView *scrollView = [[UIScrollView alloc] init]; 34 | scrollView.alwaysBounceVertical = YES; 35 | scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; 36 | self.scrollView = scrollView; 37 | [self addSubview:scrollView]; 38 | scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 39 | } 40 | 41 | - (void)setTagsModel:(NSArray *)tagsModel { 42 | CLTagView *lastTagView; 43 | CLTagView *perTagView; 44 | for (int i = 0; i < tagsModel.count; i ++) { 45 | CLTagView *tagView = [[CLTagView alloc] init]; 46 | [self.scrollView addSubview:tagView]; 47 | 48 | tagView.frame = CGRectMake(0, !i?:(CGRectGetMaxY(perTagView.frame) + kCLDistance), 0, CGRectGetMaxY(tagsModel[i].tagBtnArray.lastObject.frame)+ kCLDistance + kCLHeadViewdHeight); 49 | tagView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 50 | 51 | tagView.displayTags = self.displayTags; 52 | tagView.tags = tagsModel[i]; 53 | 54 | perTagView = tagView; 55 | if (i == tagsModel.count - 1) { 56 | lastTagView = tagView; 57 | } 58 | } 59 | 60 | CGSize scrollContenSize = self.scrollView.contentSize; 61 | scrollContenSize.height = CGRectGetMaxY(lastTagView.frame); 62 | self.scrollView.contentSize = scrollContenSize; 63 | 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /CLTageViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CLTagView/tools/CLTools.h: -------------------------------------------------------------------------------- 1 | // 2 | // Header.h 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import 10 | // 通知 11 | UIKIT_EXTERN NSString *const kCLRecentTagViewTagClickNotification; 12 | UIKIT_EXTERN NSString *const kCLRecentTagViewTagClickKey; 13 | 14 | UIKIT_EXTERN NSString *const kCLTagViewTagDeleteNotification; 15 | UIKIT_EXTERN NSString *const kCLTagViewTagDeleteKey; 16 | 17 | UIKIT_EXTERN NSString *const kCLDisplayTagViewAddTagNotification; 18 | UIKIT_EXTERN NSString *const kCLDisplayTagViewAddTagKey; 19 | UIKIT_EXTERN NSString *const kCLDisplayTagViewAddTagObject; 20 | 21 | // 16进制颜色 22 | static inline UIColor *cl_colorWithHex(uint32_t hex) { 23 | uint8_t red = (hex & 0xff0000) >> 16; 24 | uint8_t green = (hex & 0x00ff00) >> 8; 25 | uint8_t blue = hex & 0x0000ff; 26 | return [UIColor colorWithRed:red / 255.0 green:green / 255.0 blue:blue / 255.0 alpha:1.0]; 27 | } 28 | 29 | #define kCLTagFont 14 // 标签文字的大小 30 | #define kCLDistance 10 // 上下两个标签的间隙 31 | #define kCLTextFieldGap 16 // 标签中,文字距离顶部边界线(4)与底部边界线(4)的距离( 4 + 4 = 8) 32 | #define kCLTagViewWidth 80.f // 标签输入textField默认宽度,仅仅当该宽度比默认文字的总宽度大时生效 33 | #define kCLTextFieldsHorizontalGap 10 // 两个标签框的水平间距 34 | #define kCLTextFieldsVerticalGap 10 // 两个标签框的垂直间距 35 | #define kCLTagViewHorizontaGap 13 // 标签展示页水平两端的与标签的距离 36 | #define kCLDashesBorderWidth 0.8f // 标签的borderWidth 37 | 38 | // 标签展示页 39 | #define kCLTag_Normal_TextColor cl_colorWithHex(0x55b936) // 标签默认文本颜色 40 | #define kCLTag_Selected_TextColor [UIColor whiteColor] // 标签选中状态下文本颜色 41 | #define kCLTag_Normal_BorderColor cl_colorWithHex(0x55b936) // 标签默认border颜色 42 | #define kCLTag_Selected_BorderColor cl_colorWithHex(0x55b936) // 标签选中状态下border颜色 43 | #define kCLTag_Normal_BackgroundColor [UIColor whiteColor] // 标签默认背景颜色 44 | #define kCLTag_Selected_BackgroundColor cl_colorWithHex(0x55b936) // 标签选中状态下背景颜色 45 | 46 | // 最近标签页 47 | #define kCLHeadViewdHeight 44 // 最近标签页title的高度 48 | #define kCLRecentTitleFont 13 // 最近标签页title的font 49 | 50 | #define kCLRecentTag_Normal_TextColor cl_colorWithHex(0x474747) // 标签默认文本颜色 51 | #define kCLRecentTag_Selected_TextColor cl_colorWithHex(0x55b936) // 标签选中状态下文本颜色 52 | #define kCLRecentTag_Normal_BorderColor cl_colorWithHex(0xdadadd) // 标签默认border颜色 53 | #define kCLRecentTag_Selected_BorderColor cl_colorWithHex(0x55b936)// 标签选中状态下border颜色 54 | #define kCLRecentTag_Normal_BackgroundColor [UIColor whiteColor] // 标签默认背景颜色 55 | #define kCLRecentTag_Selected_BackgroundColor [UIColor clearColor] // 标签选中状态下背景颜色 56 | 57 | @interface CLTools : NSObject 58 | 59 | + (instancetype)sharedTools; 60 | 61 | /** 62 | 缓存标签的圆角半径 63 | */ 64 | @property (assign, nonatomic) CGFloat cornerRadius; 65 | 66 | @end 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CLTagView 2 | - 高仿微信标签页,快速创建标签页,可多标签组 3 | - 视图主要分为上下两个部分,和微信标签页一样,上部分为输入标签展示框,下部分为历史标签展示框 4 | 5 | ### 使用方式 6 | - 只需将**CLTagView**文件夹拖入工程,按照以下方式初始化即可 7 | - **CLTools.h**中有对标签视图相关属性的设置,如颜色,大小等 8 | 9 | #### 初始化并显示 10 | 11 | ``` 12 | // ----- 一个模型就是一个标签组 13 | CLTagsModel *model = [[CLTagsModel alloc] init]; 14 | model.title = @"所有标签"; 15 | model.tagsArray = _recentTagsM.copy; 16 | 17 | CLTagsModel *model1 = [[CLTagsModel alloc] init]; 18 | model1.title = @"第一印象"; 19 | model1.tagsArray = @[@"牛B", @"霸气", @"杜甫", @"李白", @"asdadadasd", @"1231313131", @"sdksalkjfalkjfaj", @"zvkzknmncmalkjdsfkljaskldf"]; 20 | 21 | CLTagsModel *model2 = [[CLTagsModel alloc] init]; 22 | model2.title = @"我最与众不同的是"; 23 | model2.tagsArray = @[@"确实不同", @"很不同", @"这有什么不同",@"大哥。真的不同", @"sccscasdfaf", @"adf345sdg", @"sadfl;k90808098", @"🌹,💔", @"择力", @"啫喱"]; 24 | 25 | // ----- 26 | 27 | // 创建并初始化标签控制器 28 | CLTagViewController *tagVC = [[CLTagViewController alloc] init]; 29 | tagVC.tagsDelegate = self; 30 | 31 | // 设置下半部分显示的标签组 32 | // tagVC.tagsModelArray = @[model]; 33 | tagVC.tagsModelArray = @[model, model1, model2]; // 传入多个模型,显示多个标签组 34 | 35 | // 设置上部分默认显示的标签, 不传则只显示标签的输入框 36 | tagVC.tagsDisplayArray = @[@"呵呵", @"我是打酱油的"]; 37 | 38 | // 下部分是否高亮上部分共有的标签 39 | tagVC.highlightTag = YES; 40 | 41 | // 跳转 42 | [self.navigationController pushViewController:tagVC animated:YES]; 43 | ``` 44 | 45 | ``` 46 | #pragma mark - CLTagViewControllerDelegate 点击保存,返回贴上的标签 47 | - (void)tagViewController:(CLTagViewController *)tagController tags:(NSArray *)tags { 48 | // 此代理方法中获取到贴上的标签,并做相关处理 49 | NSLog(@"%@", tags); 50 | } 51 | 52 | ``` 53 | 54 | #### CLTagViewController.h中初始化属性 55 | ``` 56 | @interface CLTagViewController : UIViewController 57 | 58 | /** 59 | 标签展示页默认显示标签 60 | */ 61 | @property (nonatomic, strong) NSArray *tagsDisplayArray; 62 | 63 | /** 64 | 最近标签页默认显示的标签 65 | */ 66 | @property (nonatomic, strong) NSArray *tagsModelArray; 67 | 68 | /** 69 | 最近标签页是否高亮展示页中相同的标签 70 | */ 71 | @property (assign, nonatomic, getter=isHighlightTag) BOOL highlightTag; 72 | 73 | /** 74 | 设置标签的圆角(不设置值则默认是控件高度的一半) 75 | */ 76 | @property (assign, nonatomic) CGFloat cornerRadius; 77 | 78 | /** 79 | 设置输入框中输入时标签的文字颜色(默认黑色) 80 | */ 81 | @property (strong, nonatomic) UIColor *normalTextColor; 82 | 83 | /** 84 | 设置输入框中输入时标签的边框颜色(默认灰色) 85 | */ 86 | @property (strong, nonatomic) UIColor *textFieldBorderColor; 87 | 88 | /** 89 | 限制单个标签最大输入的字符个数(默认是10) 90 | */ 91 | @property (assign, nonatomic) NSInteger maxStringAmount; 92 | 93 | /** 94 | 最多显示标签的行数(默认是3) 95 | */ 96 | @property (assign, nonatomic) NSInteger maxRows; 97 | ``` 98 | 99 | 100 | #### 效果如下 101 | ![Markdown](http://i2.muimg.com/583177/60989174db92d0a5.gif) 102 | -------------------------------------------------------------------------------- /CLTageViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /CLTagView/Controller/CLTagViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagViewController.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "CLTagViewController.h" 10 | #import "CLDispalyTagView.h" 11 | #import "CLRecentTagView.h" 12 | #import "CLTools.h" 13 | 14 | @interface CLTagViewController () 15 | 16 | @end 17 | 18 | @implementation CLTagViewController { 19 | CLDispalyTagView *_displayTagView; 20 | CLRecentTagView *_recentTagView; 21 | } 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | self.view.backgroundColor = [UIColor grayColor]; 26 | [self showUI]; 27 | } 28 | 29 | - (void)showUI { 30 | [CLTools sharedTools].cornerRadius = self.cornerRadius; 31 | CGFloat originalY = 0; 32 | if (self.navigationController) { 33 | originalY = 64; 34 | } 35 | self.automaticallyAdjustsScrollViewInsets = NO; 36 | _displayTagView = [[CLDispalyTagView alloc] initWithOriginalY:originalY Font:kCLTagFont]; 37 | [self.view addSubview:_displayTagView]; 38 | 39 | _recentTagView = [[CLRecentTagView alloc] init]; 40 | [self.view addSubview:_recentTagView]; 41 | 42 | _recentTagView.translatesAutoresizingMaskIntoConstraints = NO; 43 | [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"V:[_displayTagView]-0-[_recentTagView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_displayTagView,_recentTagView)]]; 44 | [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_recentTagView]-0-|" options:NSLayoutFormatAlignAllLeft | NSLayoutFormatAlignAllRight metrics:nil views:NSDictionaryOfVariableBindings(_recentTagView)]]; 45 | 46 | if (self.isHighlightTag) { 47 | _recentTagView.displayTags = self.tagsDisplayArray; 48 | } 49 | 50 | _displayTagView.maxRows = self.maxRows; 51 | _displayTagView.maxStringAmount = self.maxStringAmount; 52 | _displayTagView.normalTextColor = self.normalTextColor; 53 | _displayTagView.textFieldBorderColor = self.textFieldBorderColor; 54 | 55 | _recentTagView.tagsModel = self.tagsModelArray; 56 | _displayTagView.labels = self.tagsDisplayArray; 57 | 58 | // nav的属性,根据自己的需求更改 59 | #warning properties of navgitonController, you can reset them for your app 60 | UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 61 | [saveBtn setTitle:@"保存" forState:UIControlStateNormal]; 62 | [saveBtn setTitleColor:cl_colorWithHex(0x66d547) forState:UIControlStateNormal]; 63 | [saveBtn addTarget:self action:@selector(saveItemClick:) forControlEvents:UIControlEventTouchUpInside]; 64 | [saveBtn sizeToFit]; 65 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:saveBtn]; 66 | self.navigationController.navigationBar.barTintColor = cl_colorWithHex(0x3a393d); 67 | self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; 68 | [self.navigationController.navigationBar setTitleTextAttributes: 69 | @{NSForegroundColorAttributeName:[UIColor whiteColor]}]; 70 | 71 | self.navigationItem.title = @"标签"; 72 | } 73 | 74 | // 点击保存,获取输入的标签 75 | - (void)saveItemClick:(UIButton *)sender { 76 | // NSLog(@"%@", _displayTagView.tags); 77 | if ([self.tagsDelegate respondsToSelector:@selector(tagViewController:tags:)]) { 78 | [self.tagsDelegate tagViewController:self tags:_displayTagView.tags]; 79 | } 80 | } 81 | 82 | 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /CLTageViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CLTagViewController.h" 11 | #import "CLTagsModel.h" 12 | 13 | #ifdef DEBUG 14 | #define NSLog(fmt, ...) NSLog((@"%s [Line %d] [%s] " fmt), __FUNCTION__, __LINE__, __TIME__,##__VA_ARGS__) 15 | #else 16 | #define NSLog(...) 17 | #endif 18 | 19 | @interface ViewController () 20 | 21 | @end 22 | 23 | @implementation ViewController { 24 | UILabel *_tagsLabel; 25 | NSMutableArray *_tagArrayM; 26 | NSMutableArray *_recentTagsM; 27 | } 28 | 29 | - (void)viewWillAppear:(BOOL)animated { 30 | _tagArrayM = [[NSUserDefaults standardUserDefaults] objectForKey:@"CLTags"]; 31 | if (!_tagArrayM) { 32 | _tagArrayM = [NSMutableArray array]; 33 | } 34 | _recentTagsM = [[[NSUserDefaults standardUserDefaults] objectForKey:@"CLRecentTags"] mutableCopy]; 35 | if (!_recentTagsM) { 36 | _recentTagsM = [NSMutableArray array]; 37 | NSArray *tagsArray = @[@"帅气", @"handsome啊发发发发生", @"酷爱的法师打发", @"1111111111111", @"这是一个设sad挨打大大多", @"撒打算发发发", @"dfsafafafasfaf"]; 38 | [_recentTagsM addObjectsFromArray:tagsArray]; 39 | } 40 | } 41 | 42 | - (void)viewDidLoad { 43 | [super viewDidLoad]; 44 | // Do any additional setup after loading the view, typically from a nib. 45 | _tagsLabel = [[UILabel alloc] initWithFrame:self.view.bounds]; 46 | _tagsLabel.font = [UIFont systemFontOfSize:14]; 47 | _tagsLabel.textColor = [UIColor purpleColor]; 48 | _tagsLabel.text = @""; 49 | _tagsLabel.textAlignment = NSTextAlignmentCenter; 50 | _tagsLabel.numberOfLines = 0; 51 | [self.view addSubview:_tagsLabel]; 52 | 53 | } 54 | 55 | #pragma mark - 设置标签页的相关属性(初始化) 56 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 57 | CLTagsModel *model = [[CLTagsModel alloc] init]; 58 | model.title = @"所有标签"; 59 | model.tagsArray = _recentTagsM.copy; 60 | 61 | CLTagsModel *model1 = [[CLTagsModel alloc] init]; 62 | model1.title = @"第一印象"; 63 | model1.tagsArray = @[@"牛B", @"霸气", @"杜甫", @"李白", @"asdadadasd", @"1231313131", @"sdksalkjfalkjfaj", @"zvkzknmncmalkjdsfkljaskldf"]; 64 | 65 | CLTagsModel *model2 = [[CLTagsModel alloc] init]; 66 | model2.title = @"我最与众不同的是"; 67 | model2.tagsArray = @[@"确实不同", @"很不同", @"这有什么不同",@"大哥。真的不同", @"sccscasdfaf", @"adf345sdg", @"sadfl;k90808098", @"🌹,💔", @"择力", @"啫喱"]; 68 | 69 | CLTagViewController *tagVC = [[CLTagViewController alloc] init]; 70 | tagVC.tagsDelegate = self; 71 | // tagVC.tagsModelArray = @[model]; 72 | tagVC.tagsModelArray = @[model, model1, model2]; // 传入多个模型,显示多个标签组 73 | tagVC.tagsDisplayArray = _tagArrayM; 74 | tagVC.highlightTag = YES; 75 | [self.navigationController pushViewController:tagVC animated:YES]; 76 | _tagsLabel.text = @""; 77 | } 78 | #pragma mark - 属性设置可参照touchesBegan中的设置 79 | 80 | #pragma mark - CLTagViewControllerDelegate 返回贴上的标签,并做相关处理 81 | - (void)tagViewController:(CLTagViewController *)tagController tags:(NSArray *)tags { 82 | 83 | // 没有后台服务器。。。只能做本地处理。。。 84 | [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"CLTags"]; 85 | _tagArrayM = [NSMutableArray array]; 86 | [tagController.navigationController popViewControllerAnimated:YES]; 87 | NSLog(@"%@", tags); 88 | for (NSString *tag in tags) { 89 | if (![_recentTagsM containsObject:tag]) { 90 | [_recentTagsM addObject:tag]; 91 | } 92 | 93 | [_tagArrayM addObject:tag]; 94 | 95 | _tagsLabel.text = [[_tagsLabel.text stringByAppendingString:tag] stringByAppendingString:@" \n "]; 96 | } 97 | NSLog(@"%@", _tagsLabel.text); 98 | [[NSUserDefaults standardUserDefaults] setObject:_tagArrayM forKey:@"CLTags"]; 99 | [[NSUserDefaults standardUserDefaults] setObject:_recentTagsM forKey:@"CLRecentTags"]; 100 | 101 | } 102 | 103 | - (void)didReceiveMemoryWarning { 104 | [super didReceiveMemoryWarning]; 105 | // Dispose of any resources that can be recreated. 106 | } 107 | 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /CLTagView/View/CLTagView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagView.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/25. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "CLTagView.h" 10 | #import "CLTools.h" 11 | #import "CLTagButton.h" 12 | #import "CLTagsModel.h" 13 | 14 | @interface CLTagView () 15 | 16 | @property (nonatomic, weak) UILabel *titleLabel; 17 | @property (weak, nonatomic) UIView *tagsShowView; 18 | @property (nonatomic, strong) NSMutableDictionary *tagsCache; 19 | 20 | @end 21 | 22 | @implementation CLTagView 23 | 24 | - (instancetype)initWithFrame:(CGRect)frame { 25 | if (self = [super initWithFrame:frame]) { 26 | [self setupUI]; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)setupUI { 32 | _tagsCache = [NSMutableDictionary dictionary]; 33 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTagsStatus:) name:kCLTagViewTagDeleteNotification object:nil]; 34 | 35 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTagsStatus:) name:kCLDisplayTagViewAddTagNotification object:kCLDisplayTagViewAddTagObject]; 36 | 37 | UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, kCLHeadViewdHeight)]; 38 | [self addSubview:headView]; 39 | headView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 40 | headView.backgroundColor = cl_colorWithHex(0xf0eff3); 41 | 42 | UILabel *titleLabel = [[UILabel alloc] init]; 43 | self.titleLabel = titleLabel; 44 | titleLabel.text = @"所有标签"; 45 | titleLabel.font = [UIFont systemFontOfSize:kCLRecentTitleFont]; 46 | titleLabel.textColor = cl_colorWithHex(0x8a949b); 47 | [headView addSubview:titleLabel]; 48 | 49 | titleLabel.translatesAutoresizingMaskIntoConstraints = NO; 50 | [headView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-left-[titleLabel]-0-|" options:0 metrics:@{@"left": @(kCLTagViewHorizontaGap)} views:NSDictionaryOfVariableBindings(titleLabel)]]; 51 | [headView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[titleLabel(==height)]" options:0 metrics:@{@"height": @(kCLHeadViewdHeight)} views:NSDictionaryOfVariableBindings(titleLabel)]]; 52 | 53 | UIView *tagsShowView = [[UIView alloc] init]; 54 | tagsShowView.backgroundColor = headView.backgroundColor; 55 | self.tagsShowView = tagsShowView; 56 | [self addSubview:tagsShowView]; 57 | tagsShowView.translatesAutoresizingMaskIntoConstraints = NO; 58 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[tagsShowView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(tagsShowView)]]; 59 | [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[headView]-0-[tagsShowView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(headView, tagsShowView)]]; 60 | 61 | } 62 | 63 | - (void)setTags:(CLTagsModel *)tags{ 64 | _tags = tags; 65 | self.titleLabel.text = tags.title; 66 | [self layoutTags:tags.tagBtnArray]; 67 | } 68 | 69 | - (void)layoutTags:(NSArray *)tags { 70 | for (CLTagButton *tagBtn in tags) { 71 | tagBtn.tagBtnDelegate = self; 72 | tagBtn.layer.cornerRadius = [CLTools sharedTools].cornerRadius; 73 | [_tagsCache setObject:tagBtn forKey:tagBtn.titleLabel.text]; 74 | [self.tagsShowView addSubview:tagBtn]; 75 | } 76 | 77 | if (self.displayTags.count > 0) { 78 | for (NSString *tagDes in self.displayTags) { 79 | CLTagButton *btn =[_tagsCache objectForKey:tagDes]; 80 | if (btn) { 81 | btn.tagSelected = YES; 82 | } 83 | } 84 | } 85 | } 86 | 87 | - (void)recentTagButtonClick:(CLTagButton *)tagBtn { 88 | [[NSNotificationCenter defaultCenter] postNotificationName:kCLRecentTagViewTagClickNotification object:nil userInfo:@{kCLRecentTagViewTagClickKey: tagBtn}]; 89 | } 90 | 91 | #pragma mark - 通知 92 | - (void)reloadTagsStatus:(NSNotification *)notification { 93 | 94 | if (notification.object == nil) { 95 | CLTagButton *tagBtn = notification.userInfo[kCLTagViewTagDeleteKey]; 96 | CLTagButton *deleteTagBtn = [_tagsCache objectForKey:tagBtn.titleLabel.text]; 97 | deleteTagBtn.tagSelected = NO; 98 | return; 99 | } 100 | 101 | if ([notification.object isKindOfClass:[NSString class]]) { 102 | NSString *obj = notification.object; 103 | if ([obj isEqualToString:kCLDisplayTagViewAddTagObject]) { 104 | NSString *key = notification.userInfo[kCLDisplayTagViewAddTagKey]; 105 | CLTagButton *deleteTagBtn = [_tagsCache objectForKey:key]; 106 | deleteTagBtn.tagSelected = YES; 107 | } 108 | } 109 | } 110 | 111 | - (void)dealloc { 112 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 113 | } 114 | 115 | @end 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /CLTagView/View/CLTagButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLTagButton.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/21. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "CLTagButton.h" 10 | #import "CLTools.h" 11 | 12 | @implementation CLTagButton { 13 | UIMenuController *_menuController; 14 | } 15 | 16 | - (instancetype)initWithTextField:(UITextField *)textField { 17 | if (self = [super initWithFrame:textField.frame]) { 18 | [self initializeAttributeWithTextField:textField]; 19 | } 20 | return self; 21 | } 22 | 23 | - (void)initializeAttributeWithTextField:(UITextField *)textField { 24 | [self setTitle:textField.text forState:UIControlStateNormal]; 25 | 26 | [self setTitleColor:kCLTag_Normal_TextColor forState:UIControlStateNormal]; 27 | [self setTitleColor:kCLTag_Selected_TextColor forState:UIControlStateSelected]; 28 | 29 | [self attributeRadius:textField.layer.cornerRadius borderWidth:kCLDashesBorderWidth borderColor:kCLTag_Normal_BorderColor contentMode:UIViewContentModeCenter font:textField.font]; 30 | [self addTarget:self action:@selector(tagBtnClick:) forControlEvents:UIControlEventTouchUpInside]; 31 | } 32 | 33 | + (instancetype)initWithTagDesc:(NSString *)tagStr { 34 | CLTagButton *tagBtn = [[CLTagButton alloc] init]; 35 | [tagBtn setTitle:tagStr forState:UIControlStateNormal]; 36 | [tagBtn setTitleColor:kCLRecentTag_Normal_TextColor forState:UIControlStateNormal]; 37 | tagBtn.titleLabel.font = [UIFont systemFontOfSize:kCLTagFont]; 38 | 39 | CGSize size = [tagStr sizeWithAttributes:@{NSFontAttributeName:tagBtn.titleLabel.font}]; 40 | 41 | CGFloat height = size.height + kCLTextFieldGap; 42 | [tagBtn attributeRadius:[CLTools sharedTools].cornerRadius borderWidth:kCLDashesBorderWidth borderColor:kCLRecentTag_Normal_BorderColor contentMode:UIViewContentModeCenter font:tagBtn.titleLabel.font]; 43 | CGFloat width = size.width + height; 44 | tagBtn.frame = CGRectMake(kCLTagViewHorizontaGap, kCLDistance, width, height); 45 | [tagBtn addTarget:tagBtn action:@selector(recentTagClick:) forControlEvents:UIControlEventTouchUpInside]; 46 | return tagBtn; 47 | } 48 | 49 | - (void)attributeRadius:(CGFloat)cornerRadius borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor contentMode:(UIViewContentMode)contentMode font:(UIFont *)font{ 50 | 51 | self.layer.cornerRadius = cornerRadius; 52 | self.layer.borderWidth = borderWidth; 53 | self.layer.borderColor = borderColor.CGColor; 54 | self.titleLabel.contentMode = contentMode; 55 | self.titleLabel.font = font; 56 | } 57 | 58 | - (void)setSelected:(BOOL)selected { 59 | [super setSelected:selected]; 60 | if (self.isSelected) { 61 | self.backgroundColor = kCLTag_Selected_BackgroundColor; 62 | }else { 63 | self.backgroundColor = kCLTag_Normal_BackgroundColor; 64 | if (_isNotSelf) { 65 | _isNotSelf = NO; 66 | return; 67 | } 68 | !_menuController?:[_menuController setMenuVisible:NO animated:YES]; 69 | } 70 | } 71 | 72 | - (void)deleteItemClicked:(id)sender { 73 | self.selected = NO; 74 | if ([self.tagBtnDelegate respondsToSelector:@selector(tagButtonDelete:)]) { 75 | [self.tagBtnDelegate tagButtonDelete:self]; 76 | } 77 | } 78 | 79 | - (void)tagBtnClick:(UIButton *)sender { 80 | self.selected = !self.isSelected; 81 | if (self.selected) { 82 | _menuController = [UIMenuController sharedMenuController]; 83 | 84 | UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemClicked:)]; 85 | 86 | NSAssert([self becomeFirstResponder], @"Sorry, UIMenuController will not work with %@ since it cannot become first responder", self); 87 | [_menuController setMenuItems:[NSArray arrayWithObject:resetMenuItem]]; 88 | [_menuController setTargetRect:self.bounds inView:self]; 89 | [_menuController setMenuVisible:YES animated:YES]; 90 | } 91 | if ([self.tagBtnDelegate respondsToSelector:@selector(tagButtonDidSelected:)]) { 92 | [self.tagBtnDelegate tagButtonDidSelected:self]; 93 | } 94 | } 95 | 96 | - (void)recentTagClick:(UIButton *)sender { 97 | self.tagSelected = !self.tagSelected; 98 | 99 | if ([self.tagBtnDelegate respondsToSelector:@selector(recentTagButtonClick:)]) { 100 | [self.tagBtnDelegate recentTagButtonClick:self]; 101 | } 102 | } 103 | 104 | - (void)setTagSelected:(BOOL)tagSelected { 105 | _tagSelected = tagSelected; 106 | if (self.tagSelected) { 107 | self.backgroundColor = kCLRecentTag_Normal_BackgroundColor; 108 | [self setTitleColor:kCLRecentTag_Selected_TextColor forState:UIControlStateNormal]; 109 | self.layer.borderColor = kCLRecentTag_Selected_BorderColor.CGColor; 110 | }else { 111 | self.backgroundColor = kCLRecentTag_Selected_BackgroundColor; 112 | [self setTitleColor:kCLRecentTag_Normal_TextColor forState:UIControlStateNormal]; 113 | self.layer.borderColor = kCLRecentTag_Normal_BorderColor.CGColor; 114 | } 115 | } 116 | 117 | - (BOOL)canBecomeFirstResponder { 118 | return YES; 119 | } 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /CLTagView/View/CLDispalyTagView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CLDispalyTagView.m 3 | // CLTageViewDemo 4 | // 5 | // Created by Criss on 2017/4/20. 6 | // Copyright © 2017年 Criss. All rights reserved. 7 | // 8 | 9 | #import "CLDispalyTagView.h" 10 | #import "CLTools.h" 11 | #import "CLTagButton.h" 12 | #import "CLTagsModel.h" 13 | 14 | @class CLTagTextField; 15 | @protocol CLTagTextFieldDelegate 16 | 17 | - (void)tagTextFieldDeleteCharacter:(CLTagTextField *)tagTextField; 18 | 19 | @end 20 | @interface CLTagTextField : UITextField 21 | 22 | @property (weak, nonatomic) id tfDelegate; 23 | 24 | @end 25 | 26 | @implementation CLTagTextField 27 | 28 | - (void)deleteBackward { 29 | if ([self.tfDelegate respondsToSelector:@selector(tagTextFieldDeleteCharacter:)]) { 30 | [self.tfDelegate tagTextFieldDeleteCharacter:self]; 31 | } 32 | [super deleteBackward]; 33 | } 34 | 35 | // placeholder position 36 | - (CGRect)textRectForBounds:(CGRect)bounds { 37 | return CGRectMake(bounds.origin.x+(self.layer.cornerRadius?:3), bounds.origin.y, bounds.size.width-(self.layer.cornerRadius?:3), bounds.size.height); 38 | } 39 | 40 | // text position 41 | - (CGRect)editingRectForBounds:(CGRect)bounds { 42 | return CGRectMake(bounds.origin.x+(self.layer.cornerRadius?:3), bounds.origin.y, bounds.size.width-(self.layer.cornerRadius?:3), bounds.size.height); 43 | } 44 | 45 | - (void)layoutSubviews 46 | { 47 | [super layoutSubviews]; 48 | for (UIScrollView *view in self.subviews) 49 | { 50 | if ([view isKindOfClass:[UIScrollView class]]) 51 | { 52 | CGPoint offset = view.contentOffset; 53 | if (offset.y != 0) 54 | { 55 | offset.y = 0; 56 | view.contentOffset = offset; 57 | } 58 | break; 59 | } 60 | } 61 | } 62 | 63 | @end 64 | 65 | @interface CLDispalyTagView () 66 | 67 | @property (strong, nonatomic) CAShapeLayer *border; 68 | @property (strong, nonatomic) NSMutableArray *tagBtnArrayM; // 标签 69 | @property (strong, nonatomic) NSMutableDictionary *tagCache; 70 | 71 | 72 | @end 73 | 74 | @implementation CLDispalyTagView { 75 | CLTagTextField *_inputField; 76 | CLTagButton *_selectedBtn; 77 | UIMenuController *_menuController; 78 | 79 | CGFloat _originalWidth; 80 | CGFloat _tagHeight; 81 | NSInteger _rowsOfTags; 82 | 83 | BOOL _textFieldIsEditting; 84 | BOOL _textFieldIsDeleting; 85 | BOOL _textFieldEndEditting; 86 | } 87 | 88 | - (instancetype)initWithOriginalY:(CGFloat)originalY Font:(CGFloat)fontSize; { 89 | _inputField = [[CLTagTextField alloc] init]; 90 | _inputField.autocorrectionType = UITextAutocorrectionTypeNo; 91 | _inputField.returnKeyType = UIReturnKeyDone; 92 | _inputField.placeholder = @"输入标签"; 93 | _inputField.borderStyle = UITextBorderStyleNone; 94 | _inputField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; 95 | _inputField.autocorrectionType = UITextAutocorrectionTypeNo; 96 | fontSize? (_inputField.font = [UIFont systemFontOfSize:fontSize]): nil; 97 | [_inputField sizeToFit]; 98 | 99 | [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textFiledEditChanged:) 100 | name:UITextFieldTextDidChangeNotification 101 | object:_inputField]; 102 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTagDisplayView:) name:kCLRecentTagViewTagClickNotification object:nil]; 103 | 104 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuControllerDidHide:) name:UIMenuControllerDidHideMenuNotification object:nil]; 105 | 106 | return [self initWithFrame:CGRectMake(0, originalY, [UIScreen mainScreen].bounds.size.width, _inputField.bounds.size.height + kCLDistance * 2 + kCLTextFieldGap)]; 107 | } 108 | 109 | - (instancetype)initWithFrame:(CGRect)frame { 110 | if (self = [super initWithFrame:frame]) { 111 | [self setupUI]; 112 | } 113 | return self; 114 | } 115 | 116 | - (void)setupUI { 117 | self.backgroundColor = [UIColor whiteColor]; 118 | self.showsHorizontalScrollIndicator = NO; 119 | self.showsVerticalScrollIndicator = NO; 120 | [self addSubview:_inputField]; 121 | _inputField.delegate = self; 122 | _inputField.tfDelegate = self; 123 | _tagHeight = _inputField.bounds.size.height + kCLTextFieldGap; 124 | if (![CLTools sharedTools].cornerRadius) { 125 | [CLTools sharedTools].cornerRadius = _tagHeight * 0.5; 126 | } 127 | _inputField.layer.cornerRadius = [CLTools sharedTools].cornerRadius; 128 | _originalWidth = [self tagWidthWithText:_inputField.placeholder]; 129 | if (kCLTagViewWidth > _originalWidth) { 130 | _originalWidth = kCLTagViewWidth; 131 | } 132 | _inputField.frame = CGRectMake(kCLTagViewHorizontaGap, kCLDistance, _originalWidth, _tagHeight); 133 | } 134 | 135 | // 判断是否包含中文 136 | - (BOOL) deptNameInputShouldChineseWithString:(NSString *)string{ 137 | NSString *regex = @"[\u4e00-\u9fa5]+"; 138 | NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; 139 | if (![pred evaluateWithObject:string]) { 140 | return YES; 141 | } 142 | return NO; 143 | } 144 | 145 | - (CGFloat)tagWidthWithText:(NSString *)text { 146 | return [text sizeWithAttributes:@{NSFontAttributeName:_inputField.font}].width + _tagHeight; 147 | } 148 | 149 | #pragma mark - 通知方法 150 | 151 | - (void)menuControllerDidHide:(NSNotification *)notification { 152 | _selectedBtn.selected = NO; 153 | _selectedBtn = nil; 154 | } 155 | 156 | - (void)reloadTagDisplayView:(NSNotification *)notification { 157 | CLTagButton *tagBtn = notification.userInfo[kCLRecentTagViewTagClickKey]; 158 | // NSLog(@"%@", tagBtn.titleLabel.text); 159 | if (tagBtn.tagSelected) { 160 | if (_inputField.text.length != 0) { 161 | _textFieldIsEditting = YES; 162 | } 163 | [self addTagWithTag:tagBtn.titleLabel.text]; 164 | _textFieldIsEditting = NO; 165 | }else { 166 | [self removeTagWithTag:tagBtn.titleLabel.text]; 167 | } 168 | _selectedBtn.selected = NO; 169 | } 170 | 171 | - (void)textFiledEditChanged:(NSNotification *)obj{ 172 | 173 | UITextField *textField = (UITextField *)obj.object; 174 | 175 | if (textField.text.length == 0) { 176 | self.border.lineWidth = 0; 177 | } 178 | 179 | if (_textFieldIsDeleting) { 180 | _textFieldIsDeleting = NO; 181 | [self reloadTextField:textField allStr:textField.text]; 182 | [self textFieldDashesWithTextField:textField]; 183 | return; 184 | } 185 | 186 | NSInteger maxLength = self.maxStringAmount?:10; 187 | NSString *toBeString = textField.text; 188 | NSString *lang = [[UIApplication sharedApplication]textInputMode].primaryLanguage; // 键盘输入模式 189 | if ([lang isEqualToString:@"zh-Hans"]) { // 简体中文输入,包括简体拼音,健体五笔,简体手写 190 | UITextRange *selectedRange = [textField markedTextRange]; 191 | //获取高亮部分 192 | UITextPosition *position = [textField positionFromPosition:selectedRange.start offset:0]; 193 | // 没有高亮选择的字,则对已输入的文字进行字数统计和限制 194 | if (!position) { 195 | if (toBeString.length > maxLength) { 196 | textField.text = [toBeString substringToIndex:maxLength]; 197 | } 198 | [self reloadTextField:textField allStr:textField.text]; 199 | } 200 | // 有高亮选择的字符串,则暂不对文字进行统计和限制 201 | else{ 202 | } 203 | 204 | } 205 | [self textFieldDashesWithTextField:textField]; 206 | [self layoutIfNeeded]; 207 | } 208 | 209 | #pragma mark - UITextFieldDelegate 210 | - (void)textFieldDidBeginEditing:(UITextField *)textField { 211 | if (_selectedBtn) { 212 | _selectedBtn.selected = NO; 213 | } 214 | } 215 | 216 | - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 217 | if ([string isEqualToString:@" "] && textField.text.length == 0) { 218 | return NO; 219 | } 220 | 221 | if ([string isEqualToString:@""]) { 222 | _textFieldIsDeleting = YES; 223 | return YES; 224 | } 225 | 226 | if (textField.text.length == 0 && _selectedBtn) { 227 | _selectedBtn.selected = NO; 228 | _selectedBtn = nil; 229 | } 230 | 231 | NSInteger maxLength = self.maxStringAmount?:10; 232 | NSString *lang = [[UIApplication sharedApplication]textInputMode].primaryLanguage; 233 | 234 | if (![lang isEqualToString:@"zh-Hans"]) { 235 | if (textField.text.length + string.length > maxLength) { 236 | return NO; 237 | } 238 | }else { 239 | if (![self deptNameInputShouldChineseWithString:string]) { 240 | return YES; 241 | } 242 | } 243 | NSString *allStr = [textField.text stringByAppendingString:string]; 244 | return [self reloadTextField:textField allStr:allStr]; 245 | } 246 | 247 | - (BOOL)textFieldShouldReturn:(UITextField *)textField { 248 | if (textField.text.length == 0) { 249 | return YES; 250 | } 251 | 252 | [self addTagWithTag:textField.text]; 253 | 254 | [[NSNotificationCenter defaultCenter] postNotificationName:kCLDisplayTagViewAddTagNotification object:kCLDisplayTagViewAddTagObject userInfo:@{kCLDisplayTagViewAddTagKey : textField.text}]; 255 | 256 | textField.text = @""; 257 | self.border.lineWidth = 0; 258 | 259 | return YES; 260 | } 261 | 262 | // 更新textField的frame 263 | - (BOOL)reloadTextField:(UITextField *)textField allStr:(NSString *)allStr { 264 | CGFloat width = [self tagWidthWithText:allStr]; 265 | CGRect rect = textField.frame; 266 | if (width > self.bounds.size.width - kCLTagViewHorizontaGap * 2) { 267 | return YES; 268 | } 269 | 270 | if (width > _originalWidth) { 271 | rect.size.width = width; 272 | }else { 273 | rect.size.width = _originalWidth; 274 | } 275 | textField.frame = rect; 276 | _textFieldIsEditting = YES; 277 | [self reloadTagViewPreTag:self.tagBtnArrayM.lastObject currentTagBtn:textField]; 278 | _textFieldIsEditting = NO; 279 | return YES; 280 | } 281 | 282 | - (void)addTagWithTag:(NSString *)text { 283 | if (![self.tagCache objectForKey:text]) { 284 | CLTagButton *tagBtn = [[CLTagButton alloc] initWithTextField:_inputField]; 285 | CGFloat width = [self tagWidthWithText:text]; 286 | [tagBtn setTitle:text forState:UIControlStateNormal]; 287 | tagBtn.frame = CGRectMake(_inputField.frame.origin.x, _inputField.frame.origin.y, width, tagBtn.bounds.size.height); 288 | [self reloadTagViewPreTag:self.tagBtnArrayM.lastObject currentTagBtn:tagBtn]; 289 | tagBtn.tagBtnDelegate = self; 290 | [self addSubview:tagBtn]; 291 | [self.tagBtnArrayM addObject:tagBtn]; 292 | [self.tagCache setObject:tagBtn forKey:text]; 293 | [self reloadTagViewPreTag:tagBtn currentTagBtn:_inputField]; 294 | [self textFieldDashesWithTextField:_inputField]; 295 | } 296 | } 297 | 298 | - (void)removeTagWithTag:(NSString *)tag { 299 | CLTagButton *tagbtn = [self.tagCache objectForKey:tag]; 300 | NSInteger index = [self.tagBtnArrayM indexOfObject:tagbtn]; 301 | [self.tagCache removeObjectForKey:tag]; 302 | [self.tagBtnArrayM[index] removeFromSuperview]; 303 | [self.tagBtnArrayM removeObjectAtIndex:index]; 304 | 305 | [[NSNotificationCenter defaultCenter] postNotificationName:kCLTagViewTagDeleteNotification object:nil userInfo:@{kCLTagViewTagDeleteKey: tagbtn}]; 306 | 307 | if (index == self.tagBtnArrayM.count) { 308 | [self reloadTagViewPreTag:self.tagBtnArrayM.lastObject currentTagBtn:_inputField]; 309 | return; 310 | } 311 | for (NSInteger i = index; i < self.tagBtnArrayM.count; i ++) { 312 | [self reloadTagViewPreTag:i?self.tagBtnArrayM[i - 1]:nil currentTagBtn:self.tagBtnArrayM[i]]; 313 | } 314 | [self reloadTagViewPreTag:self.tagBtnArrayM.lastObject currentTagBtn:_inputField]; 315 | 316 | } 317 | 318 | - (void)reloadTagViewPreTag:(UIView *)preTagBtn currentTagBtn:(UIView *)currentTagBtn { 319 | if ([currentTagBtn isKindOfClass:[CLTagTextField class]]) { 320 | if (!_textFieldIsEditting) { 321 | CGRect rect = currentTagBtn.frame; 322 | rect.size.width = _originalWidth; 323 | currentTagBtn.frame = rect; 324 | } 325 | } 326 | 327 | CGFloat preTaling = preTagBtn? CGRectGetMaxX(preTagBtn.frame) : 0; 328 | CGFloat preBottom = preTagBtn? CGRectGetMaxY(preTagBtn.frame) : 0; 329 | CGFloat preY = preTagBtn? preTagBtn.frame.origin.y : kCLDistance; 330 | 331 | if (preTaling + kCLTagViewHorizontaGap * 2 + currentTagBtn.bounds.size.width > self.bounds.size.width) { 332 | currentTagBtn.frame = CGRectMake(kCLTagViewHorizontaGap, preBottom + kCLTextFieldsVerticalGap, currentTagBtn.frame.size.width, currentTagBtn.frame.size.height); 333 | }else { 334 | currentTagBtn.frame = CGRectMake(preTaling + kCLTextFieldsHorizontalGap, preY, currentTagBtn.frame.size.width, currentTagBtn.frame.size.height); 335 | } 336 | 337 | if ([currentTagBtn isKindOfClass:[CLTagTextField class]]) { 338 | CGFloat tagViewHeight = self.contentSize.height; 339 | CGFloat tagViewExpectHeight = CGRectGetMaxY(currentTagBtn.frame) + kCLDistance; 340 | if (tagViewExpectHeight > tagViewHeight) { 341 | _rowsOfTags ++; 342 | } 343 | 344 | if (tagViewExpectHeight < tagViewHeight) { 345 | _rowsOfTags --; 346 | } 347 | 348 | self.contentSize = CGSizeMake(self.frame.size.width, tagViewExpectHeight); 349 | if (_rowsOfTags > (self.maxRows?:3)) { 350 | self.showsVerticalScrollIndicator = YES; 351 | // 滑动到底部 352 | CGRect bottomRect = CGRectMake(0, self.contentSize.height - 1 , 1, 1); 353 | [self scrollRectToVisible:bottomRect animated:NO]; 354 | return; 355 | } 356 | self.showsVerticalScrollIndicator = NO; 357 | if (tagViewHeight != tagViewExpectHeight) { 358 | CGRect tagViewRect = self.frame; 359 | tagViewRect.size.height = tagViewExpectHeight; 360 | self.frame = tagViewRect; 361 | } 362 | 363 | } 364 | } 365 | 366 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 367 | if (_selectedBtn) { 368 | _selectedBtn.selected = NO; 369 | _selectedBtn = nil; 370 | } 371 | [_inputField becomeFirstResponder]; 372 | } 373 | 374 | #pragma mark - CLTagButtonDelegate 375 | - (void)tagButtonDelete:(CLTagButton *)tagBtn { 376 | [self removeTagWithTag:tagBtn.titleLabel.text]; 377 | if (_inputField.text.length) { 378 | [_inputField becomeFirstResponder]; 379 | } 380 | _selectedBtn = nil; 381 | } 382 | 383 | - (void)tagButtonDidSelected:(CLTagButton *)tagBtn { 384 | _selectedBtn.isNotSelf = YES; 385 | _selectedBtn.selected = NO; 386 | _selectedBtn = tagBtn.isSelected? tagBtn: nil; 387 | if (!tagBtn.selected) { 388 | [_inputField becomeFirstResponder]; 389 | } 390 | } 391 | 392 | #pragma mark - CLTagTextFieldDelegate 393 | - (void)tagTextFieldDeleteCharacter:(CLTagTextField *)tagTextField { 394 | _textFieldIsDeleting = YES; 395 | if (tagTextField.text.length ==0) { 396 | if (self.tagBtnArrayM.count > 0) { 397 | CLTagButton *lastBtn = self.tagBtnArrayM.lastObject; 398 | if (!lastBtn.isSelected) { 399 | lastBtn.selected = YES; 400 | _selectedBtn = lastBtn; 401 | }else { 402 | _selectedBtn.selected = NO; 403 | [self removeTagWithTag:lastBtn.titleLabel.text]; 404 | } 405 | } 406 | } 407 | } 408 | 409 | #pragma mark - 虚线边框 410 | - (void)textFieldDashesWithTextField:(UITextField *)textField { 411 | textField.borderStyle = UITextBorderStyleNone; 412 | if (self.border) { 413 | if (self.border.lineWidth == 0 && textField.text.length != 0) { 414 | self.border.lineWidth = kCLDashesBorderWidth; 415 | } 416 | self.border.path = [UIBezierPath bezierPathWithRoundedRect:textField.bounds cornerRadius:textField.layer.cornerRadius].CGPath; 417 | return; 418 | } 419 | CAShapeLayer *border = [CAShapeLayer layer]; 420 | 421 | border.strokeColor = self.textFieldBorderColor.CGColor?:cl_colorWithHex(0xdadadd).CGColor; 422 | 423 | border.fillColor = nil; 424 | 425 | border.path = [UIBezierPath bezierPathWithRoundedRect:textField.bounds cornerRadius:textField.layer.cornerRadius].CGPath; 426 | 427 | border.frame = textField.bounds; 428 | 429 | if (_inputField.text.length == 0) { 430 | border.lineWidth = 0; 431 | }else { 432 | border.lineWidth = kCLDashesBorderWidth; 433 | } 434 | 435 | border.lineCap = @"round"; 436 | 437 | border.lineDashPattern = @[@4, @2]; 438 | self.border = border; 439 | 440 | [textField.layer addSublayer:border]; 441 | } 442 | 443 | -(void)dealloc{ 444 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 445 | } 446 | 447 | - (NSArray *)tags { 448 | return [self.tagCache allKeys]; 449 | } 450 | 451 | - (void)setLabels:(NSArray *)labels { 452 | _labels = labels; 453 | for (NSString *des in labels) { 454 | [self addTagWithTag:des]; 455 | } 456 | } 457 | 458 | #pragma mark - lazy 459 | - (NSMutableArray *)tagBtnArrayM { 460 | if (!_tagBtnArrayM) { 461 | _tagBtnArrayM = [NSMutableArray array]; 462 | } 463 | return _tagBtnArrayM; 464 | } 465 | 466 | - (NSMutableDictionary *)tagCache { 467 | if (!_tagCache) { 468 | _tagCache = [[NSMutableDictionary alloc] init]; 469 | } 470 | return _tagCache; 471 | } 472 | @end 473 | -------------------------------------------------------------------------------- /CLTageViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 289748511EA853BA00060A09 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 289748501EA853BA00060A09 /* main.m */; }; 11 | 289748541EA853BA00060A09 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 289748531EA853BA00060A09 /* AppDelegate.m */; }; 12 | 289748571EA853BA00060A09 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 289748561EA853BA00060A09 /* ViewController.m */; }; 13 | 2897485A1EA853BA00060A09 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 289748581EA853BA00060A09 /* Main.storyboard */; }; 14 | 2897485C1EA853BA00060A09 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2897485B1EA853BA00060A09 /* Assets.xcassets */; }; 15 | 2897485F1EA853BA00060A09 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2897485D1EA853BA00060A09 /* LaunchScreen.storyboard */; }; 16 | 2897486A1EA853BA00060A09 /* CLTageViewDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 289748691EA853BA00060A09 /* CLTageViewDemoTests.m */; }; 17 | 289748751EA853BA00060A09 /* CLTageViewDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 289748741EA853BA00060A09 /* CLTageViewDemoUITests.m */; }; 18 | FC3B9B561EDB25B20016B573 /* CLTagViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3B9B461EDB25B20016B573 /* CLTagViewController.m */; }; 19 | FC3B9B571EDB25B20016B573 /* CLTagsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3B9B491EDB25B20016B573 /* CLTagsModel.m */; }; 20 | FC3B9B581EDB25B20016B573 /* CLTools.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3B9B4C1EDB25B20016B573 /* CLTools.m */; }; 21 | FC3B9B591EDB25B20016B573 /* CLDispalyTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3B9B4F1EDB25B20016B573 /* CLDispalyTagView.m */; }; 22 | FC3B9B5A1EDB25B20016B573 /* CLRecentTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3B9B511EDB25B20016B573 /* CLRecentTagView.m */; }; 23 | FC3B9B5B1EDB25B20016B573 /* CLTagButton.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3B9B531EDB25B20016B573 /* CLTagButton.m */; }; 24 | FC3B9B5C1EDB25B20016B573 /* CLTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3B9B551EDB25B20016B573 /* CLTagView.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 289748661EA853BA00060A09 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 289748441EA853BA00060A09 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 2897484B1EA853BA00060A09; 33 | remoteInfo = CLTageViewDemo; 34 | }; 35 | 289748711EA853BA00060A09 /* PBXContainerItemProxy */ = { 36 | isa = PBXContainerItemProxy; 37 | containerPortal = 289748441EA853BA00060A09 /* Project object */; 38 | proxyType = 1; 39 | remoteGlobalIDString = 2897484B1EA853BA00060A09; 40 | remoteInfo = CLTageViewDemo; 41 | }; 42 | /* End PBXContainerItemProxy section */ 43 | 44 | /* Begin PBXFileReference section */ 45 | 2897484C1EA853BA00060A09 /* CLTageViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CLTageViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 289748501EA853BA00060A09 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 47 | 289748521EA853BA00060A09 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 48 | 289748531EA853BA00060A09 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 49 | 289748551EA853BA00060A09 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 50 | 289748561EA853BA00060A09 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 51 | 289748591EA853BA00060A09 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 52 | 2897485B1EA853BA00060A09 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 53 | 2897485E1EA853BA00060A09 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 54 | 289748651EA853BA00060A09 /* CLTageViewDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CLTageViewDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 289748691EA853BA00060A09 /* CLTageViewDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CLTageViewDemoTests.m; sourceTree = ""; }; 56 | 2897486B1EA853BA00060A09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 289748701EA853BA00060A09 /* CLTageViewDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CLTageViewDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 289748741EA853BA00060A09 /* CLTageViewDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CLTageViewDemoUITests.m; sourceTree = ""; }; 59 | 289748761EA853BA00060A09 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | FC3B9B451EDB25B20016B573 /* CLTagViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLTagViewController.h; sourceTree = ""; }; 61 | FC3B9B461EDB25B20016B573 /* CLTagViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLTagViewController.m; sourceTree = ""; }; 62 | FC3B9B481EDB25B20016B573 /* CLTagsModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLTagsModel.h; sourceTree = ""; }; 63 | FC3B9B491EDB25B20016B573 /* CLTagsModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLTagsModel.m; sourceTree = ""; }; 64 | FC3B9B4B1EDB25B20016B573 /* CLTools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLTools.h; sourceTree = ""; }; 65 | FC3B9B4C1EDB25B20016B573 /* CLTools.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLTools.m; sourceTree = ""; }; 66 | FC3B9B4E1EDB25B20016B573 /* CLDispalyTagView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLDispalyTagView.h; sourceTree = ""; }; 67 | FC3B9B4F1EDB25B20016B573 /* CLDispalyTagView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLDispalyTagView.m; sourceTree = ""; }; 68 | FC3B9B501EDB25B20016B573 /* CLRecentTagView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLRecentTagView.h; sourceTree = ""; }; 69 | FC3B9B511EDB25B20016B573 /* CLRecentTagView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLRecentTagView.m; sourceTree = ""; }; 70 | FC3B9B521EDB25B20016B573 /* CLTagButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLTagButton.h; sourceTree = ""; }; 71 | FC3B9B531EDB25B20016B573 /* CLTagButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLTagButton.m; sourceTree = ""; }; 72 | FC3B9B541EDB25B20016B573 /* CLTagView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLTagView.h; sourceTree = ""; }; 73 | FC3B9B551EDB25B20016B573 /* CLTagView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLTagView.m; sourceTree = ""; }; 74 | /* End PBXFileReference section */ 75 | 76 | /* Begin PBXFrameworksBuildPhase section */ 77 | 289748491EA853BA00060A09 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | 289748621EA853BA00060A09 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | 2897486D1EA853BA00060A09 /* Frameworks */ = { 92 | isa = PBXFrameworksBuildPhase; 93 | buildActionMask = 2147483647; 94 | files = ( 95 | ); 96 | runOnlyForDeploymentPostprocessing = 0; 97 | }; 98 | /* End PBXFrameworksBuildPhase section */ 99 | 100 | /* Begin PBXGroup section */ 101 | 289748431EA853BA00060A09 = { 102 | isa = PBXGroup; 103 | children = ( 104 | FC3B9B431EDB25B20016B573 /* CLTagView */, 105 | 2897484E1EA853BA00060A09 /* CLTageViewDemo */, 106 | 289748681EA853BA00060A09 /* CLTageViewDemoTests */, 107 | 289748731EA853BA00060A09 /* CLTageViewDemoUITests */, 108 | 2897484D1EA853BA00060A09 /* Products */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 2897484D1EA853BA00060A09 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 2897484C1EA853BA00060A09 /* CLTageViewDemo.app */, 116 | 289748651EA853BA00060A09 /* CLTageViewDemoTests.xctest */, 117 | 289748701EA853BA00060A09 /* CLTageViewDemoUITests.xctest */, 118 | ); 119 | name = Products; 120 | sourceTree = ""; 121 | }; 122 | 2897484E1EA853BA00060A09 /* CLTageViewDemo */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 289748521EA853BA00060A09 /* AppDelegate.h */, 126 | 289748531EA853BA00060A09 /* AppDelegate.m */, 127 | 289748551EA853BA00060A09 /* ViewController.h */, 128 | 289748561EA853BA00060A09 /* ViewController.m */, 129 | 289748581EA853BA00060A09 /* Main.storyboard */, 130 | 2897485B1EA853BA00060A09 /* Assets.xcassets */, 131 | 2897485D1EA853BA00060A09 /* LaunchScreen.storyboard */, 132 | 2897484F1EA853BA00060A09 /* Supporting Files */, 133 | ); 134 | path = CLTageViewDemo; 135 | sourceTree = ""; 136 | }; 137 | 2897484F1EA853BA00060A09 /* Supporting Files */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | 289748501EA853BA00060A09 /* main.m */, 141 | ); 142 | name = "Supporting Files"; 143 | sourceTree = ""; 144 | }; 145 | 289748681EA853BA00060A09 /* CLTageViewDemoTests */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 289748691EA853BA00060A09 /* CLTageViewDemoTests.m */, 149 | 2897486B1EA853BA00060A09 /* Info.plist */, 150 | ); 151 | path = CLTageViewDemoTests; 152 | sourceTree = ""; 153 | }; 154 | 289748731EA853BA00060A09 /* CLTageViewDemoUITests */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | 289748741EA853BA00060A09 /* CLTageViewDemoUITests.m */, 158 | 289748761EA853BA00060A09 /* Info.plist */, 159 | ); 160 | path = CLTageViewDemoUITests; 161 | sourceTree = ""; 162 | }; 163 | FC3B9B431EDB25B20016B573 /* CLTagView */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | FC3B9B441EDB25B20016B573 /* Controller */, 167 | FC3B9B471EDB25B20016B573 /* Model */, 168 | FC3B9B4A1EDB25B20016B573 /* tools */, 169 | FC3B9B4D1EDB25B20016B573 /* View */, 170 | ); 171 | path = CLTagView; 172 | sourceTree = ""; 173 | }; 174 | FC3B9B441EDB25B20016B573 /* Controller */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | FC3B9B451EDB25B20016B573 /* CLTagViewController.h */, 178 | FC3B9B461EDB25B20016B573 /* CLTagViewController.m */, 179 | ); 180 | path = Controller; 181 | sourceTree = ""; 182 | }; 183 | FC3B9B471EDB25B20016B573 /* Model */ = { 184 | isa = PBXGroup; 185 | children = ( 186 | FC3B9B481EDB25B20016B573 /* CLTagsModel.h */, 187 | FC3B9B491EDB25B20016B573 /* CLTagsModel.m */, 188 | ); 189 | path = Model; 190 | sourceTree = ""; 191 | }; 192 | FC3B9B4A1EDB25B20016B573 /* tools */ = { 193 | isa = PBXGroup; 194 | children = ( 195 | FC3B9B4B1EDB25B20016B573 /* CLTools.h */, 196 | FC3B9B4C1EDB25B20016B573 /* CLTools.m */, 197 | ); 198 | path = tools; 199 | sourceTree = ""; 200 | }; 201 | FC3B9B4D1EDB25B20016B573 /* View */ = { 202 | isa = PBXGroup; 203 | children = ( 204 | FC3B9B4E1EDB25B20016B573 /* CLDispalyTagView.h */, 205 | FC3B9B4F1EDB25B20016B573 /* CLDispalyTagView.m */, 206 | FC3B9B501EDB25B20016B573 /* CLRecentTagView.h */, 207 | FC3B9B511EDB25B20016B573 /* CLRecentTagView.m */, 208 | FC3B9B521EDB25B20016B573 /* CLTagButton.h */, 209 | FC3B9B531EDB25B20016B573 /* CLTagButton.m */, 210 | FC3B9B541EDB25B20016B573 /* CLTagView.h */, 211 | FC3B9B551EDB25B20016B573 /* CLTagView.m */, 212 | ); 213 | path = View; 214 | sourceTree = ""; 215 | }; 216 | /* End PBXGroup section */ 217 | 218 | /* Begin PBXNativeTarget section */ 219 | 2897484B1EA853BA00060A09 /* CLTageViewDemo */ = { 220 | isa = PBXNativeTarget; 221 | buildConfigurationList = 289748791EA853BA00060A09 /* Build configuration list for PBXNativeTarget "CLTageViewDemo" */; 222 | buildPhases = ( 223 | 289748481EA853BA00060A09 /* Sources */, 224 | 289748491EA853BA00060A09 /* Frameworks */, 225 | 2897484A1EA853BA00060A09 /* Resources */, 226 | ); 227 | buildRules = ( 228 | ); 229 | dependencies = ( 230 | ); 231 | name = CLTageViewDemo; 232 | productName = CLTageViewDemo; 233 | productReference = 2897484C1EA853BA00060A09 /* CLTageViewDemo.app */; 234 | productType = "com.apple.product-type.application"; 235 | }; 236 | 289748641EA853BA00060A09 /* CLTageViewDemoTests */ = { 237 | isa = PBXNativeTarget; 238 | buildConfigurationList = 2897487C1EA853BA00060A09 /* Build configuration list for PBXNativeTarget "CLTageViewDemoTests" */; 239 | buildPhases = ( 240 | 289748611EA853BA00060A09 /* Sources */, 241 | 289748621EA853BA00060A09 /* Frameworks */, 242 | 289748631EA853BA00060A09 /* Resources */, 243 | ); 244 | buildRules = ( 245 | ); 246 | dependencies = ( 247 | 289748671EA853BA00060A09 /* PBXTargetDependency */, 248 | ); 249 | name = CLTageViewDemoTests; 250 | productName = CLTageViewDemoTests; 251 | productReference = 289748651EA853BA00060A09 /* CLTageViewDemoTests.xctest */; 252 | productType = "com.apple.product-type.bundle.unit-test"; 253 | }; 254 | 2897486F1EA853BA00060A09 /* CLTageViewDemoUITests */ = { 255 | isa = PBXNativeTarget; 256 | buildConfigurationList = 2897487F1EA853BA00060A09 /* Build configuration list for PBXNativeTarget "CLTageViewDemoUITests" */; 257 | buildPhases = ( 258 | 2897486C1EA853BA00060A09 /* Sources */, 259 | 2897486D1EA853BA00060A09 /* Frameworks */, 260 | 2897486E1EA853BA00060A09 /* Resources */, 261 | ); 262 | buildRules = ( 263 | ); 264 | dependencies = ( 265 | 289748721EA853BA00060A09 /* PBXTargetDependency */, 266 | ); 267 | name = CLTageViewDemoUITests; 268 | productName = CLTageViewDemoUITests; 269 | productReference = 289748701EA853BA00060A09 /* CLTageViewDemoUITests.xctest */; 270 | productType = "com.apple.product-type.bundle.ui-testing"; 271 | }; 272 | /* End PBXNativeTarget section */ 273 | 274 | /* Begin PBXProject section */ 275 | 289748441EA853BA00060A09 /* Project object */ = { 276 | isa = PBXProject; 277 | attributes = { 278 | LastUpgradeCheck = 0830; 279 | ORGANIZATIONNAME = Criss; 280 | TargetAttributes = { 281 | 2897484B1EA853BA00060A09 = { 282 | CreatedOnToolsVersion = 8.3; 283 | ProvisioningStyle = Automatic; 284 | }; 285 | 289748641EA853BA00060A09 = { 286 | CreatedOnToolsVersion = 8.3; 287 | ProvisioningStyle = Automatic; 288 | TestTargetID = 2897484B1EA853BA00060A09; 289 | }; 290 | 2897486F1EA853BA00060A09 = { 291 | CreatedOnToolsVersion = 8.3; 292 | ProvisioningStyle = Automatic; 293 | TestTargetID = 2897484B1EA853BA00060A09; 294 | }; 295 | }; 296 | }; 297 | buildConfigurationList = 289748471EA853BA00060A09 /* Build configuration list for PBXProject "CLTageViewDemo" */; 298 | compatibilityVersion = "Xcode 3.2"; 299 | developmentRegion = English; 300 | hasScannedForEncodings = 0; 301 | knownRegions = ( 302 | en, 303 | Base, 304 | ); 305 | mainGroup = 289748431EA853BA00060A09; 306 | productRefGroup = 2897484D1EA853BA00060A09 /* Products */; 307 | projectDirPath = ""; 308 | projectRoot = ""; 309 | targets = ( 310 | 2897484B1EA853BA00060A09 /* CLTageViewDemo */, 311 | 289748641EA853BA00060A09 /* CLTageViewDemoTests */, 312 | 2897486F1EA853BA00060A09 /* CLTageViewDemoUITests */, 313 | ); 314 | }; 315 | /* End PBXProject section */ 316 | 317 | /* Begin PBXResourcesBuildPhase section */ 318 | 2897484A1EA853BA00060A09 /* Resources */ = { 319 | isa = PBXResourcesBuildPhase; 320 | buildActionMask = 2147483647; 321 | files = ( 322 | 2897485F1EA853BA00060A09 /* LaunchScreen.storyboard in Resources */, 323 | 2897485C1EA853BA00060A09 /* Assets.xcassets in Resources */, 324 | 2897485A1EA853BA00060A09 /* Main.storyboard in Resources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | 289748631EA853BA00060A09 /* Resources */ = { 329 | isa = PBXResourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | }; 335 | 2897486E1EA853BA00060A09 /* Resources */ = { 336 | isa = PBXResourcesBuildPhase; 337 | buildActionMask = 2147483647; 338 | files = ( 339 | ); 340 | runOnlyForDeploymentPostprocessing = 0; 341 | }; 342 | /* End PBXResourcesBuildPhase section */ 343 | 344 | /* Begin PBXSourcesBuildPhase section */ 345 | 289748481EA853BA00060A09 /* Sources */ = { 346 | isa = PBXSourcesBuildPhase; 347 | buildActionMask = 2147483647; 348 | files = ( 349 | FC3B9B591EDB25B20016B573 /* CLDispalyTagView.m in Sources */, 350 | 289748571EA853BA00060A09 /* ViewController.m in Sources */, 351 | FC3B9B5C1EDB25B20016B573 /* CLTagView.m in Sources */, 352 | 289748541EA853BA00060A09 /* AppDelegate.m in Sources */, 353 | FC3B9B5B1EDB25B20016B573 /* CLTagButton.m in Sources */, 354 | FC3B9B5A1EDB25B20016B573 /* CLRecentTagView.m in Sources */, 355 | FC3B9B581EDB25B20016B573 /* CLTools.m in Sources */, 356 | FC3B9B561EDB25B20016B573 /* CLTagViewController.m in Sources */, 357 | FC3B9B571EDB25B20016B573 /* CLTagsModel.m in Sources */, 358 | 289748511EA853BA00060A09 /* main.m in Sources */, 359 | ); 360 | runOnlyForDeploymentPostprocessing = 0; 361 | }; 362 | 289748611EA853BA00060A09 /* Sources */ = { 363 | isa = PBXSourcesBuildPhase; 364 | buildActionMask = 2147483647; 365 | files = ( 366 | 2897486A1EA853BA00060A09 /* CLTageViewDemoTests.m in Sources */, 367 | ); 368 | runOnlyForDeploymentPostprocessing = 0; 369 | }; 370 | 2897486C1EA853BA00060A09 /* Sources */ = { 371 | isa = PBXSourcesBuildPhase; 372 | buildActionMask = 2147483647; 373 | files = ( 374 | 289748751EA853BA00060A09 /* CLTageViewDemoUITests.m in Sources */, 375 | ); 376 | runOnlyForDeploymentPostprocessing = 0; 377 | }; 378 | /* End PBXSourcesBuildPhase section */ 379 | 380 | /* Begin PBXTargetDependency section */ 381 | 289748671EA853BA00060A09 /* PBXTargetDependency */ = { 382 | isa = PBXTargetDependency; 383 | target = 2897484B1EA853BA00060A09 /* CLTageViewDemo */; 384 | targetProxy = 289748661EA853BA00060A09 /* PBXContainerItemProxy */; 385 | }; 386 | 289748721EA853BA00060A09 /* PBXTargetDependency */ = { 387 | isa = PBXTargetDependency; 388 | target = 2897484B1EA853BA00060A09 /* CLTageViewDemo */; 389 | targetProxy = 289748711EA853BA00060A09 /* PBXContainerItemProxy */; 390 | }; 391 | /* End PBXTargetDependency section */ 392 | 393 | /* Begin PBXVariantGroup section */ 394 | 289748581EA853BA00060A09 /* Main.storyboard */ = { 395 | isa = PBXVariantGroup; 396 | children = ( 397 | 289748591EA853BA00060A09 /* Base */, 398 | ); 399 | name = Main.storyboard; 400 | sourceTree = ""; 401 | }; 402 | 2897485D1EA853BA00060A09 /* LaunchScreen.storyboard */ = { 403 | isa = PBXVariantGroup; 404 | children = ( 405 | 2897485E1EA853BA00060A09 /* Base */, 406 | ); 407 | name = LaunchScreen.storyboard; 408 | sourceTree = ""; 409 | }; 410 | /* End PBXVariantGroup section */ 411 | 412 | /* Begin XCBuildConfiguration section */ 413 | 289748771EA853BA00060A09 /* Debug */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | ALWAYS_SEARCH_USER_PATHS = NO; 417 | CLANG_ANALYZER_NONNULL = YES; 418 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 419 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 420 | CLANG_CXX_LIBRARY = "libc++"; 421 | CLANG_ENABLE_MODULES = YES; 422 | CLANG_ENABLE_OBJC_ARC = YES; 423 | CLANG_WARN_BOOL_CONVERSION = YES; 424 | CLANG_WARN_CONSTANT_CONVERSION = YES; 425 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 426 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 427 | CLANG_WARN_EMPTY_BODY = YES; 428 | CLANG_WARN_ENUM_CONVERSION = YES; 429 | CLANG_WARN_INFINITE_RECURSION = YES; 430 | CLANG_WARN_INT_CONVERSION = YES; 431 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 432 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 433 | CLANG_WARN_UNREACHABLE_CODE = YES; 434 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 435 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 436 | COPY_PHASE_STRIP = NO; 437 | DEBUG_INFORMATION_FORMAT = dwarf; 438 | ENABLE_STRICT_OBJC_MSGSEND = YES; 439 | ENABLE_TESTABILITY = YES; 440 | GCC_C_LANGUAGE_STANDARD = gnu99; 441 | GCC_DYNAMIC_NO_PIC = NO; 442 | GCC_NO_COMMON_BLOCKS = YES; 443 | GCC_OPTIMIZATION_LEVEL = 0; 444 | GCC_PREPROCESSOR_DEFINITIONS = ( 445 | "DEBUG=1", 446 | "$(inherited)", 447 | ); 448 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 449 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 450 | GCC_WARN_UNDECLARED_SELECTOR = YES; 451 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 452 | GCC_WARN_UNUSED_FUNCTION = YES; 453 | GCC_WARN_UNUSED_VARIABLE = YES; 454 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 455 | MTL_ENABLE_DEBUG_INFO = YES; 456 | ONLY_ACTIVE_ARCH = YES; 457 | SDKROOT = iphoneos; 458 | TARGETED_DEVICE_FAMILY = "1,2"; 459 | }; 460 | name = Debug; 461 | }; 462 | 289748781EA853BA00060A09 /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | ALWAYS_SEARCH_USER_PATHS = NO; 466 | CLANG_ANALYZER_NONNULL = YES; 467 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 468 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 469 | CLANG_CXX_LIBRARY = "libc++"; 470 | CLANG_ENABLE_MODULES = YES; 471 | CLANG_ENABLE_OBJC_ARC = YES; 472 | CLANG_WARN_BOOL_CONVERSION = YES; 473 | CLANG_WARN_CONSTANT_CONVERSION = YES; 474 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 475 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 476 | CLANG_WARN_EMPTY_BODY = YES; 477 | CLANG_WARN_ENUM_CONVERSION = YES; 478 | CLANG_WARN_INFINITE_RECURSION = YES; 479 | CLANG_WARN_INT_CONVERSION = YES; 480 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 481 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 482 | CLANG_WARN_UNREACHABLE_CODE = YES; 483 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 484 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 485 | COPY_PHASE_STRIP = NO; 486 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 487 | ENABLE_NS_ASSERTIONS = NO; 488 | ENABLE_STRICT_OBJC_MSGSEND = YES; 489 | GCC_C_LANGUAGE_STANDARD = gnu99; 490 | GCC_NO_COMMON_BLOCKS = YES; 491 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 492 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 493 | GCC_WARN_UNDECLARED_SELECTOR = YES; 494 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 495 | GCC_WARN_UNUSED_FUNCTION = YES; 496 | GCC_WARN_UNUSED_VARIABLE = YES; 497 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 498 | MTL_ENABLE_DEBUG_INFO = NO; 499 | SDKROOT = iphoneos; 500 | TARGETED_DEVICE_FAMILY = "1,2"; 501 | VALIDATE_PRODUCT = YES; 502 | }; 503 | name = Release; 504 | }; 505 | 2897487A1EA853BA00060A09 /* Debug */ = { 506 | isa = XCBuildConfiguration; 507 | buildSettings = { 508 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 509 | INFOPLIST_FILE = CLTageViewDemo/Info.plist; 510 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 511 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 512 | PRODUCT_BUNDLE_IDENTIFIER = com.criss.CLTageViewDemo; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | }; 515 | name = Debug; 516 | }; 517 | 2897487B1EA853BA00060A09 /* Release */ = { 518 | isa = XCBuildConfiguration; 519 | buildSettings = { 520 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 521 | INFOPLIST_FILE = CLTageViewDemo/Info.plist; 522 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 523 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 524 | PRODUCT_BUNDLE_IDENTIFIER = com.criss.CLTageViewDemo; 525 | PRODUCT_NAME = "$(TARGET_NAME)"; 526 | }; 527 | name = Release; 528 | }; 529 | 2897487D1EA853BA00060A09 /* Debug */ = { 530 | isa = XCBuildConfiguration; 531 | buildSettings = { 532 | BUNDLE_LOADER = "$(TEST_HOST)"; 533 | INFOPLIST_FILE = CLTageViewDemoTests/Info.plist; 534 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 535 | PRODUCT_BUNDLE_IDENTIFIER = com.criss.CLTageViewDemoTests; 536 | PRODUCT_NAME = "$(TARGET_NAME)"; 537 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CLTageViewDemo.app/CLTageViewDemo"; 538 | }; 539 | name = Debug; 540 | }; 541 | 2897487E1EA853BA00060A09 /* Release */ = { 542 | isa = XCBuildConfiguration; 543 | buildSettings = { 544 | BUNDLE_LOADER = "$(TEST_HOST)"; 545 | INFOPLIST_FILE = CLTageViewDemoTests/Info.plist; 546 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 547 | PRODUCT_BUNDLE_IDENTIFIER = com.criss.CLTageViewDemoTests; 548 | PRODUCT_NAME = "$(TARGET_NAME)"; 549 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CLTageViewDemo.app/CLTageViewDemo"; 550 | }; 551 | name = Release; 552 | }; 553 | 289748801EA853BA00060A09 /* Debug */ = { 554 | isa = XCBuildConfiguration; 555 | buildSettings = { 556 | INFOPLIST_FILE = CLTageViewDemoUITests/Info.plist; 557 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 558 | PRODUCT_BUNDLE_IDENTIFIER = com.criss.CLTageViewDemoUITests; 559 | PRODUCT_NAME = "$(TARGET_NAME)"; 560 | TEST_TARGET_NAME = CLTageViewDemo; 561 | }; 562 | name = Debug; 563 | }; 564 | 289748811EA853BA00060A09 /* Release */ = { 565 | isa = XCBuildConfiguration; 566 | buildSettings = { 567 | INFOPLIST_FILE = CLTageViewDemoUITests/Info.plist; 568 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 569 | PRODUCT_BUNDLE_IDENTIFIER = com.criss.CLTageViewDemoUITests; 570 | PRODUCT_NAME = "$(TARGET_NAME)"; 571 | TEST_TARGET_NAME = CLTageViewDemo; 572 | }; 573 | name = Release; 574 | }; 575 | /* End XCBuildConfiguration section */ 576 | 577 | /* Begin XCConfigurationList section */ 578 | 289748471EA853BA00060A09 /* Build configuration list for PBXProject "CLTageViewDemo" */ = { 579 | isa = XCConfigurationList; 580 | buildConfigurations = ( 581 | 289748771EA853BA00060A09 /* Debug */, 582 | 289748781EA853BA00060A09 /* Release */, 583 | ); 584 | defaultConfigurationIsVisible = 0; 585 | defaultConfigurationName = Release; 586 | }; 587 | 289748791EA853BA00060A09 /* Build configuration list for PBXNativeTarget "CLTageViewDemo" */ = { 588 | isa = XCConfigurationList; 589 | buildConfigurations = ( 590 | 2897487A1EA853BA00060A09 /* Debug */, 591 | 2897487B1EA853BA00060A09 /* Release */, 592 | ); 593 | defaultConfigurationIsVisible = 0; 594 | defaultConfigurationName = Release; 595 | }; 596 | 2897487C1EA853BA00060A09 /* Build configuration list for PBXNativeTarget "CLTageViewDemoTests" */ = { 597 | isa = XCConfigurationList; 598 | buildConfigurations = ( 599 | 2897487D1EA853BA00060A09 /* Debug */, 600 | 2897487E1EA853BA00060A09 /* Release */, 601 | ); 602 | defaultConfigurationIsVisible = 0; 603 | defaultConfigurationName = Release; 604 | }; 605 | 2897487F1EA853BA00060A09 /* Build configuration list for PBXNativeTarget "CLTageViewDemoUITests" */ = { 606 | isa = XCConfigurationList; 607 | buildConfigurations = ( 608 | 289748801EA853BA00060A09 /* Debug */, 609 | 289748811EA853BA00060A09 /* Release */, 610 | ); 611 | defaultConfigurationIsVisible = 0; 612 | defaultConfigurationName = Release; 613 | }; 614 | /* End XCConfigurationList section */ 615 | }; 616 | rootObject = 289748441EA853BA00060A09 /* Project object */; 617 | } 618 | --------------------------------------------------------------------------------