diff --git a/Classes/Base.lproj/Main.storyboard b/Classes/Base.lproj/Main.storyboard index 90b461c..aa14adb 100644 --- a/Classes/Base.lproj/Main.storyboard +++ b/Classes/Base.lproj/Main.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -14,62 +18,62 @@ - + - + - + - + @@ -105,25 +109,25 @@ - + - - - + + + - + - + - + - - + + @@ -159,9 +163,9 @@ - + - + @@ -175,7 +179,7 @@ - + diff --git a/Classes/CustomTagButton.h b/Classes/CustomTagButton.h new file mode 100644 index 0000000..f423737 --- /dev/null +++ b/Classes/CustomTagButton.h @@ -0,0 +1,15 @@ +// +// CustomTagButton.h +// SKTagView +// +// Created by zhangchong on 2018/1/17. +// Copyright © 2018年 shiweifu. All rights reserved. +// + +#import "SKTagButton.h" + +@interface CustomTagButton : SKTagButton + ++ (nonnull instancetype)buttonWithTag: (nonnull SKTag *)tag; + +@end diff --git a/Classes/CustomTagButton.m b/Classes/CustomTagButton.m new file mode 100644 index 0000000..da83e7b --- /dev/null +++ b/Classes/CustomTagButton.m @@ -0,0 +1,90 @@ +// +// CustomTagButton.m +// SKTagView +// +// Created by zhangchong on 2018/1/17. +// Copyright © 2018年 shiweifu. All rights reserved. +// + +#import "CustomTagButton.h" +#import "SKTag.h" + +static const CGFloat kLeftOffsetOfImageToTitle = 8.f; +static const CGFloat kLeftOffsetOfTitleToButton = 13.f; +static const CGFloat kRightOffsetOfTitleToButton = 35.f; + +@implementation CustomTagButton + ++ (nonnull instancetype)buttonWithTag: (nonnull SKTag *)tag { + CustomTagButton *btn = [super buttonWithType:UIButtonTypeCustom]; + + if (tag.attributedText) { + [btn setAttributedTitle: tag.attributedText forState: UIControlStateNormal]; + } else { + [btn setTitle: tag.text forState:UIControlStateNormal]; + [btn setImage: tag.image forState:UIControlStateNormal]; + [btn setTitleColor: tag.textColor forState: UIControlStateNormal]; + btn.titleLabel.font = tag.font ?: [UIFont systemFontOfSize: tag.fontSize]; + } + + btn.backgroundColor = tag.bgColor; + btn.contentEdgeInsets = tag.padding; + btn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; + + if (tag.bgImg) { + [btn setBackgroundImage: tag.bgImg forState: UIControlStateNormal]; + } + + if (tag.borderColor) { + btn.layer.borderColor = tag.borderColor.CGColor; + } + + if (tag.borderWidth) { + btn.layer.borderWidth = tag.borderWidth; + } + + btn.userInteractionEnabled = tag.enable; + if (tag.enable) { + UIColor *highlightedBgColor = tag.highlightedBgColor ?: [self darkerColor:btn.backgroundColor]; + [btn setBackgroundImage:[self imageWithColor:highlightedBgColor] forState:UIControlStateHighlighted]; + } + + btn.layer.cornerRadius = tag.cornerRadius; + btn.layer.masksToBounds = YES; + + return btn; +} + +- (void)layoutSubviews { + [super layoutSubviews]; + + if (self.imageView) { +// NSLog(@"imageEdgeInsets: %@", NSStringFromUIEdgeInsets(self.imageEdgeInsets)); +// NSLog(@"titleEdgeInsets: %@", NSStringFromUIEdgeInsets(self.titleEdgeInsets)); + + self.imageEdgeInsets = UIEdgeInsetsMake(0, (self.titleLabel.frame.size.width + kLeftOffsetOfImageToTitle), + 0, -(self.titleLabel.frame.size.width + kLeftOffsetOfImageToTitle)); + self.titleEdgeInsets = UIEdgeInsetsMake(0, -(self.imageView.frame.size.width), 0, + self.imageView.frame.size.width); + + } + + NSLog(@"line:[%@] bounds:[%@] titleFrame:[%@] imageFrame:[%@]", + @(__LINE__), + NSStringFromCGRect(self.bounds), + NSStringFromCGRect(self.titleLabel.frame), + NSStringFromCGRect(self.imageView.frame)); +} + +- (CGSize)intrinsicContentSize { + CGSize titleSize = [self.titleLabel intrinsicContentSize]; + CGSize imageSize = [self.imageView intrinsicContentSize]; + NSLog(@"line:[%@] titleSize:[%@], imageSize:[%@]", + @(__LINE__), + NSStringFromCGSize(titleSize), + NSStringFromCGSize(imageSize)); + CGSize size = CGSizeMake(kLeftOffsetOfTitleToButton + titleSize.width + kRightOffsetOfTitleToButton, 32); + return size; +} + +@end diff --git a/Classes/Images.xcassets/AppIcon.appiconset/Contents.json b/Classes/Images.xcassets/AppIcon.appiconset/Contents.json index 118c98f..19882d5 100644 --- a/Classes/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Classes/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -29,6 +39,11 @@ "idiom" : "iphone", "size" : "60x60", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/Classes/Images.xcassets/Contents.json b/Classes/Images.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Classes/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Classes/Images.xcassets/Icons/Contents.json b/Classes/Images.xcassets/Icons/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Classes/Images.xcassets/Icons/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Classes/Images.xcassets/Icons/icon_delete.imageset/Contents.json b/Classes/Images.xcassets/Icons/icon_delete.imageset/Contents.json new file mode 100644 index 0000000..0cdeec0 --- /dev/null +++ b/Classes/Images.xcassets/Icons/icon_delete.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "filename" : "tagDelete.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Classes/Images.xcassets/Icons/icon_delete.imageset/tagDelete.pdf b/Classes/Images.xcassets/Icons/icon_delete.imageset/tagDelete.pdf new file mode 100644 index 0000000..4342061 Binary files /dev/null and b/Classes/Images.xcassets/Icons/icon_delete.imageset/tagDelete.pdf differ diff --git a/Classes/ViewController.m b/Classes/ViewController.m index 8589784..428b405 100644 --- a/Classes/ViewController.m +++ b/Classes/ViewController.m @@ -8,6 +8,7 @@ #import "ViewController.h" #import "SKTagView.h" +#import "CustomTagButton.h" #import #import @@ -24,12 +25,31 @@ - (void)viewDidLoad { self.colors = @[@"#7ecef4", @"#84ccc9", @"#88abda", @"#7dc1dd", @"#b6b8de"]; [self setupTagView]; + + CustomTagButton *button = [CustomTagButton buttonWithType:UIButtonTypeCustom]; + button.backgroundColor = [UIColor redColor]; + [button setImage:[UIImage imageNamed:@"icon_delete"] forState:UIControlStateNormal]; + [button setTitle:@"Islam" forState:UIControlStateNormal]; + [button setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal]; + button.titleLabel.backgroundColor = [UIColor greenColor]; + button.imageView.backgroundColor = [UIColor orangeColor]; + [self.view addSubview:button]; + [button mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.view).offset(100); + make.left.equalTo(self.view).offset(100); + }]; + + UIView *rulerView = [[UIView alloc] initWithFrame:CGRectMake(0, -5, 13.f, 40.f)]; + rulerView.backgroundColor = [UIColor blackColor]; + [button addSubview:rulerView]; + } #pragma mark - Private - (void)setupTagView { self.tagView = ({ SKTagView *view = [SKTagView new]; + view.buttonClass = [CustomTagButton class]; view.backgroundColor = [UIColor whiteColor]; view.padding = UIEdgeInsetsMake(12, 12, 12, 12); view.interitemSpacing = 15; @@ -55,7 +75,8 @@ - (void)setupTagView { tag.fontSize = 15; //tag.font = [UIFont fontWithName:@"Courier" size:15]; //tag.enable = NO; - tag.padding = UIEdgeInsetsMake(13.5, 12.5, 13.5, 12.5); + tag.image = [UIImage imageNamed:@"icon_delete"]; +// tag.padding = UIEdgeInsetsMake(13.5, 12.5, 13.5, 12.5); tag.bgColor = [UIColor hx_colorWithHexString: self.colors[idx % self.colors.count]]; tag.cornerRadius = 5; [self.tagView addTag:tag]; diff --git a/Podfile.lock b/Podfile.lock index e3d8f6e..9790287 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -10,4 +10,6 @@ SPEC CHECKSUMS: HexColors: 8b83e3fe90c0d466dae7b98c9d22da95799f99cb Masonry: ff105a956abcd19a618b2028b121cb638d7a8e2f -COCOAPODS: 0.39.0 +PODFILE CHECKSUM: ba993a1eb31f2d8d78d30ad14d61b95fbaa97d7f + +COCOAPODS: 1.3.1 diff --git a/SKTagView.xcodeproj/project.pbxproj b/SKTagView.xcodeproj/project.pbxproj index 91d452f..8273dec 100644 --- a/SKTagView.xcodeproj/project.pbxproj +++ b/SKTagView.xcodeproj/project.pbxproj @@ -7,7 +7,8 @@ objects = { /* Begin PBXBuildFile section */ - 3760C1D68DC6E6DCD0629E1C /* libPods-SKTagView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46328B9142A4A0B33379D3CE /* libPods-SKTagView.a */; }; + 0E888B5A7A91C33E6649E110 /* libPods-SKTagView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22872617A8486166837A285F /* libPods-SKTagView.a */; }; + 678E7CB9200E5FF700A604D5 /* CustomTagButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 678E7CB8200E5FF700A604D5 /* CustomTagButton.m */; }; 682ABA701A36933300D57A1A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA6F1A36933300D57A1A /* main.m */; }; 682ABA731A36933300D57A1A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA721A36933300D57A1A /* AppDelegate.m */; }; 682ABA761A36933300D57A1A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA751A36933300D57A1A /* ViewController.m */; }; @@ -16,6 +17,7 @@ 682ABA7E1A36933300D57A1A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 682ABA7C1A36933300D57A1A /* LaunchScreen.xib */; }; 682ABA951A3693BC00D57A1A /* SKTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA941A3693BC00D57A1A /* SKTagView.m */; }; 6AB277B71AE2A80700D92167 /* SKTagViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6AB277B61AE2A80700D92167 /* SKTagViewTests.m */; }; + 7122B19BEED2F10AE0C3EB57 /* libPods-SKTagViewTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BF05C349EEA9CE729A0FB60C /* libPods-SKTagViewTests.a */; }; D865CB921A6415B200F3592C /* TagsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D865CB911A6415B200F3592C /* TagsTableViewController.m */; }; D865CB951A64160500F3592C /* TagsTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D865CB941A64160500F3592C /* TagsTableCell.m */; }; E198833B70106A7B969AF9D2 /* SKTag.m in Sources */ = {isa = PBXBuildFile; fileRef = E198883D944B29B6488A5B34 /* SKTag.m */; }; @@ -33,8 +35,11 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 34A8B7A699E830DE1102943F /* Pods-SKTagView.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SKTagView.release.xcconfig"; path = "Pods/Target Support Files/Pods-SKTagView/Pods-SKTagView.release.xcconfig"; sourceTree = ""; }; - 46328B9142A4A0B33379D3CE /* libPods-SKTagView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SKTagView.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1B84CDC3A1BA2989D656DBAD /* Pods-SKTagViewTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SKTagViewTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SKTagViewTests/Pods-SKTagViewTests.release.xcconfig"; sourceTree = ""; }; + 22872617A8486166837A285F /* libPods-SKTagView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SKTagView.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 61C9320B25C50A0C6DF4F19C /* Pods-SKTagView.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SKTagView.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SKTagView/Pods-SKTagView.debug.xcconfig"; sourceTree = ""; }; + 678E7CB7200E5FF700A604D5 /* CustomTagButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomTagButton.h; sourceTree = ""; }; + 678E7CB8200E5FF700A604D5 /* CustomTagButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomTagButton.m; sourceTree = ""; }; 682ABA6A1A36933300D57A1A /* SKTagView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SKTagView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 682ABA6E1A36933300D57A1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 682ABA6F1A36933300D57A1A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -50,11 +55,13 @@ 682ABA931A3693BC00D57A1A /* SKTagView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKTagView.h; sourceTree = ""; }; 682ABA941A3693BC00D57A1A /* SKTagView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKTagView.m; sourceTree = ""; }; 6AB277B61AE2A80700D92167 /* SKTagViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKTagViewTests.m; sourceTree = ""; }; - 6E4B93550F83909B378F1930 /* Pods-SKTagView.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SKTagView.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SKTagView/Pods-SKTagView.debug.xcconfig"; sourceTree = ""; }; + B5BE9CF37778B4E1132BD0DA /* Pods-SKTagView.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SKTagView.release.xcconfig"; path = "Pods/Target Support Files/Pods-SKTagView/Pods-SKTagView.release.xcconfig"; sourceTree = ""; }; + BF05C349EEA9CE729A0FB60C /* libPods-SKTagViewTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SKTagViewTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; D865CB901A6415B200F3592C /* TagsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagsTableViewController.h; sourceTree = ""; }; D865CB911A6415B200F3592C /* TagsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TagsTableViewController.m; sourceTree = ""; }; D865CB931A64160500F3592C /* TagsTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagsTableCell.h; sourceTree = ""; }; D865CB941A64160500F3592C /* TagsTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TagsTableCell.m; sourceTree = ""; }; + DA3DAE646C441786010FC99C /* Pods-SKTagViewTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SKTagViewTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SKTagViewTests/Pods-SKTagViewTests.debug.xcconfig"; sourceTree = ""; }; E19884C2F2577114719748BD /* SKTagButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKTagButton.h; sourceTree = ""; }; E198883D944B29B6488A5B34 /* SKTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKTag.m; sourceTree = ""; }; E1988A206257CAF7FE6FC77A /* SKTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKTag.h; sourceTree = ""; }; @@ -66,7 +73,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3760C1D68DC6E6DCD0629E1C /* libPods-SKTagView.a in Frameworks */, + 0E888B5A7A91C33E6649E110 /* libPods-SKTagView.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -74,12 +81,33 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 7122B19BEED2F10AE0C3EB57 /* libPods-SKTagViewTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0C4C2FCF367D6C03F4AE3FD2 /* Pods */ = { + isa = PBXGroup; + children = ( + 61C9320B25C50A0C6DF4F19C /* Pods-SKTagView.debug.xcconfig */, + B5BE9CF37778B4E1132BD0DA /* Pods-SKTagView.release.xcconfig */, + DA3DAE646C441786010FC99C /* Pods-SKTagViewTests.debug.xcconfig */, + 1B84CDC3A1BA2989D656DBAD /* Pods-SKTagViewTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 3BA1498DE3A8090322DDE501 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 22872617A8486166837A285F /* libPods-SKTagView.a */, + BF05C349EEA9CE729A0FB60C /* libPods-SKTagViewTests.a */, + ); + name = Frameworks; + sourceTree = ""; + }; 682ABA611A36933300D57A1A = { isa = PBXGroup; children = ( @@ -87,8 +115,8 @@ 682ABA6C1A36933300D57A1A /* Classes */, 682ABA861A36933300D57A1A /* SKTagViewTests */, 682ABA6B1A36933300D57A1A /* Products */, - 8E977D293B7744A3F0911ED5 /* Pods */, - E9B8B9417B704821F5FF7698 /* Frameworks */, + 0C4C2FCF367D6C03F4AE3FD2 /* Pods */, + 3BA1498DE3A8090322DDE501 /* Frameworks */, ); sourceTree = ""; }; @@ -116,6 +144,8 @@ 682ABA7C1A36933300D57A1A /* LaunchScreen.xib */, 682ABA7A1A36933300D57A1A /* Images.xcassets */, 682ABA6D1A36933300D57A1A /* Supporting Files */, + 678E7CB7200E5FF700A604D5 /* CustomTagButton.h */, + 678E7CB8200E5FF700A604D5 /* CustomTagButton.m */, ); path = Classes; sourceTree = ""; @@ -146,15 +176,6 @@ name = "Supporting Files"; sourceTree = ""; }; - 8E977D293B7744A3F0911ED5 /* Pods */ = { - isa = PBXGroup; - children = ( - 6E4B93550F83909B378F1930 /* Pods-SKTagView.debug.xcconfig */, - 34A8B7A699E830DE1102943F /* Pods-SKTagView.release.xcconfig */, - ); - name = Pods; - sourceTree = ""; - }; CB3B6CFF1A5E27C9008911FF /* SKTagView */ = { isa = PBXGroup; children = ( @@ -162,20 +183,12 @@ 682ABA941A3693BC00D57A1A /* SKTagView.m */, E198883D944B29B6488A5B34 /* SKTag.m */, E1988A206257CAF7FE6FC77A /* SKTag.h */, - E1988DC652E4B5A7DD3FC44D /* SKTagButton.m */, E19884C2F2577114719748BD /* SKTagButton.h */, + E1988DC652E4B5A7DD3FC44D /* SKTagButton.m */, ); path = SKTagView; sourceTree = ""; }; - E9B8B9417B704821F5FF7698 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 46328B9142A4A0B33379D3CE /* libPods-SKTagView.a */, - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -183,12 +196,12 @@ isa = PBXNativeTarget; buildConfigurationList = 682ABA8D1A36933300D57A1A /* Build configuration list for PBXNativeTarget "SKTagView" */; buildPhases = ( - 56A572FD8CB365055FBC8C48 /* Check Pods Manifest.lock */, + 1344FCD465825703C8914A85 /* [CP] Check Pods Manifest.lock */, 682ABA661A36933300D57A1A /* Sources */, 682ABA671A36933300D57A1A /* Frameworks */, 682ABA681A36933300D57A1A /* Resources */, - FAE40ECF28B915D0419B9B28 /* Copy Pods Resources */, - 7EED09FF7F430376584E2BA7 /* Embed Pods Frameworks */, + 49BB3D6A9570E8895DD9A071 /* [CP] Embed Pods Frameworks */, + D61E69E75055DCBB7CC27A11 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -203,9 +216,12 @@ isa = PBXNativeTarget; buildConfigurationList = 682ABA901A36933300D57A1A /* Build configuration list for PBXNativeTarget "SKTagViewTests" */; buildPhases = ( + CA73E84116773EB32D50CBE8 /* [CP] Check Pods Manifest.lock */, 682ABA7F1A36933300D57A1A /* Sources */, 682ABA801A36933300D57A1A /* Frameworks */, 682ABA811A36933300D57A1A /* Resources */, + 5B9E808BDFFE374476D8D3C0 /* [CP] Embed Pods Frameworks */, + D924746B5640C36A9048D842 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -228,7 +244,7 @@ TargetAttributes = { 682ABA691A36933300D57A1A = { CreatedOnToolsVersion = 6.0; - DevelopmentTeam = Z59GEMSQ7R; + DevelopmentTeam = AD9385276N; }; 682ABA821A36933300D57A1A = { CreatedOnToolsVersion = 6.0; @@ -276,29 +292,32 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 56A572FD8CB365055FBC8C48 /* Check Pods Manifest.lock */ = { + 1344FCD465825703C8914A85 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "Check Pods Manifest.lock"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-SKTagView-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 7EED09FF7F430376584E2BA7 /* Embed Pods Frameworks */ = { + 49BB3D6A9570E8895DD9A071 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -306,14 +325,47 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SKTagView/Pods-SKTagView-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - FAE40ECF28B915D0419B9B28 /* Copy Pods Resources */ = { + 5B9E808BDFFE374476D8D3C0 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SKTagViewTests/Pods-SKTagViewTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + CA73E84116773EB32D50CBE8 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "Copy Pods Resources"; + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-SKTagViewTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + D61E69E75055DCBB7CC27A11 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -321,6 +373,21 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SKTagView/Pods-SKTagView-resources.sh\"\n"; showEnvVarsInLog = 0; }; + D924746B5640C36A9048D842 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SKTagViewTests/Pods-SKTagViewTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -331,6 +398,7 @@ 682ABA761A36933300D57A1A /* ViewController.m in Sources */, D865CB951A64160500F3592C /* TagsTableCell.m in Sources */, 682ABA731A36933300D57A1A /* AppDelegate.m in Sources */, + 678E7CB9200E5FF700A604D5 /* CustomTagButton.m in Sources */, 682ABA951A3693BC00D57A1A /* SKTagView.m in Sources */, D865CB921A6415B200F3592C /* TagsTableViewController.m in Sources */, 682ABA701A36933300D57A1A /* main.m in Sources */, @@ -456,13 +524,14 @@ }; 682ABA8E1A36933300D57A1A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 6E4B93550F83909B378F1930 /* Pods-SKTagView.debug.xcconfig */; + baseConfigurationReference = 61C9320B25C50A0C6DF4F19C /* Pods-SKTagView.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; + DEVELOPMENT_TEAM = AD9385276N; INFOPLIST_FILE = Classes/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.coloshine.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = com.diamondstudio.SKTagView; PRODUCT_NAME = SKTagView; USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/Pods\"/**"; }; @@ -470,13 +539,14 @@ }; 682ABA8F1A36933300D57A1A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 34A8B7A699E830DE1102943F /* Pods-SKTagView.release.xcconfig */; + baseConfigurationReference = B5BE9CF37778B4E1132BD0DA /* Pods-SKTagView.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; + DEVELOPMENT_TEAM = AD9385276N; INFOPLIST_FILE = Classes/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.coloshine.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = com.diamondstudio.SKTagView; PRODUCT_NAME = SKTagView; USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/Pods\"/**"; }; @@ -484,6 +554,7 @@ }; 682ABA911A36933300D57A1A /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DA3DAE646C441786010FC99C /* Pods-SKTagViewTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( @@ -504,6 +575,7 @@ }; 682ABA921A36933300D57A1A /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 1B84CDC3A1BA2989D656DBAD /* Pods-SKTagViewTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( diff --git a/SKTagView/SKTag.h b/SKTagView/SKTag.h index 9a03afd..ed9ca14 100644 --- a/SKTagView/SKTag.h +++ b/SKTagView/SKTag.h @@ -9,6 +9,7 @@ @interface SKTag : NSObject @property (copy, nonatomic, nullable) NSString *text; +@property (strong, nonatomic, nullable) UIImage *image; @property (copy, nonatomic, nullable) NSAttributedString *attributedText; @property (strong, nonatomic, nullable) UIColor *textColor; ///backgound color diff --git a/SKTagView/SKTagButton.h b/SKTagView/SKTagButton.h index ed55716..da584ce 100644 --- a/SKTagView/SKTagButton.h +++ b/SKTagView/SKTagButton.h @@ -10,5 +10,6 @@ @interface SKTagButton: UIButton + (nonnull instancetype)buttonWithTag: (nonnull SKTag *)tag; - -@end \ No newline at end of file ++ (nonnull UIImage *)imageWithColor:(UIColor *)color; ++ (nonnull UIColor *)darkerColor:(UIColor *)color; +@end diff --git a/SKTagView/SKTagView.h b/SKTagView/SKTagView.h index 306633b..f491417 100644 --- a/SKTagView/SKTagView.h +++ b/SKTagView/SKTagView.h @@ -16,6 +16,7 @@ @property (assign, nonatomic) CGFloat preferredMaxLayoutWidth; @property (assign, nonatomic) BOOL singleLine; @property (copy, nonatomic, nullable) void (^didTapTagAtIndex)(NSUInteger index); +@property (strong, nonatomic, nullable) Class buttonClass; - (void)addTag: (nonnull SKTag *)tag; - (void)insertTag: (nonnull SKTag *)tag atIndex:(NSUInteger)index; diff --git a/SKTagView/SKTagView.m b/SKTagView/SKTagView.m index 27e1217..7821f49 100644 --- a/SKTagView/SKTagView.m +++ b/SKTagView/SKTagView.m @@ -164,7 +164,12 @@ - (void)onTag: (UIButton *)btn { - (void)addTag: (SKTag *)tag { NSParameterAssert(tag); - SKTagButton *btn = [SKTagButton buttonWithTag: tag]; + SKTagButton *btn = nil; + if (self.buttonClass) { + btn = [self.buttonClass buttonWithTag: tag]; + } else { + btn = [SKTagButton buttonWithTag: tag]; + } [btn addTarget: self action: @selector(onTag:) forControlEvents: UIControlEventTouchUpInside]; [self addSubview: btn]; [self.tags addObject: tag]; @@ -178,7 +183,12 @@ - (void)insertTag: (SKTag *)tag atIndex: (NSUInteger)index { if (index + 1 > self.tags.count) { [self addTag: tag]; } else { - SKTagButton *btn = [SKTagButton buttonWithTag: tag]; + SKTagButton *btn = nil; + if (self.buttonClass) { + btn = [self.buttonClass buttonWithTag: tag]; + } else { + btn = [SKTagButton buttonWithTag: tag]; + } [btn addTarget: self action: @selector(onTag:) forControlEvents: UIControlEventTouchUpInside]; [self insertSubview: btn atIndex: index]; [self.tags insertObject: tag atIndex: index];