├── SFTagView-1.png ├── SFTagView-2.png ├── WrapViewWithAutolayout.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── project.pbxproj ├── WrapViewWithAutolayout ├── SFTagButton.h ├── AppDelegate.h ├── SFTagButton.m ├── main.m ├── ViewController.h ├── SFTagView.h ├── SFTag.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── SFTag.h ├── Info.plist ├── NSString+ObjectiveSugar.h ├── NSString+ObjectiveSugar.m ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── ViewController.m └── SFTagView.m ├── .gitignore ├── WrapViewWithAutolayoutTests ├── Info.plist └── WrapViewWithAutolayoutTests.m ├── LICENSE.md ├── SFTagView.podspec └── README.md /SFTagView-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweifu/SFTagView/HEAD/SFTagView-1.png -------------------------------------------------------------------------------- /SFTagView-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shiweifu/SFTagView/HEAD/SFTagView-2.png -------------------------------------------------------------------------------- /WrapViewWithAutolayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/SFTagButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by shiweifu on 12/9/14. 3 | // Copyright (c) 2014 shiweifu. All rights reserved. 4 | // 5 | 6 | #import 7 | #import 8 | 9 | @interface SFTagButton : UIButton 10 | @end -------------------------------------------------------------------------------- /WrapViewWithAutolayout/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WrapViewWithAutolayout 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. 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 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/SFTagButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by shiweifu on 12/9/14. 3 | // Copyright (c) 2014 shiweifu. All rights reserved. 4 | // 5 | 6 | #import "SFTagButton.h" 7 | 8 | 9 | @implementation SFTagButton 10 | { 11 | 12 | } 13 | 14 | - (CGSize)intrinsicContentSize 15 | { 16 | CGSize size = [super intrinsicContentSize]; 17 | size.width += 10; 18 | return size; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WrapViewWithAutolayout 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. 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 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WrapViewWithAutolayout 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | - (IBAction)handleAddTag:(id)sender; 14 | @end 15 | 16 | 17 | @interface UIColor (Test) 18 | 19 | +(UIColor *)tagBgColor; 20 | 21 | +(UIColor *)tagTextColor; 22 | 23 | @end 24 | 25 | 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 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 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | Pods/ 27 | # 28 | 29 | .DS_Store 30 | .idea 31 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/SFTagView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SFTagView.h 3 | // WrapViewWithAutolayout 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class SFTag; 12 | 13 | @interface SFTagView : UIView 14 | 15 | 16 | @property (nonatomic, assign) UIEdgeInsets margin; 17 | @property (nonatomic, assign) int lineSpace; 18 | @property (nonatomic, assign) CGFloat insets; 19 | 20 | // 0左对其 1右对其 21 | @property (nonatomic, assign) NSInteger alignment; 22 | 23 | - (void)addTag:(SFTag *)tag; 24 | 25 | - (void)removeAllTags; 26 | 27 | - (void)removeTagText:(NSString *)text; 28 | @end 29 | 30 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/SFTag.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by shiweifu on 12/9/14. 3 | // Copyright (c) 2014 shiweifu. All rights reserved. 4 | // 5 | 6 | #import "SFTag.h" 7 | 8 | 9 | @implementation SFTag 10 | { 11 | 12 | } 13 | 14 | - (instancetype)initWithText:(NSString *)text 15 | { 16 | self = [super init]; 17 | if (self) 18 | { 19 | _text = text; 20 | self.font = [UIFont systemFontOfSize:14]; 21 | self.textColor = [UIColor blackColor]; 22 | self.bgColor = [UIColor whiteColor]; 23 | } 24 | 25 | return self; 26 | } 27 | 28 | + (instancetype)tagWithText:(NSString *)text 29 | { 30 | return [[self alloc] initWithText:text]; 31 | } 32 | 33 | 34 | @end -------------------------------------------------------------------------------- /WrapViewWithAutolayout/Images.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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /WrapViewWithAutolayout/SFTag.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by shiweifu on 12/9/14. 3 | // Copyright (c) 2014 shiweifu. All rights reserved. 4 | // 5 | 6 | #import 7 | #import 8 | 9 | @interface SFTag : NSObject 10 | 11 | @property (nonatomic, strong) NSString *text; 12 | 13 | @property (nonatomic, strong) UIColor *textColor; 14 | 15 | @property (nonatomic, strong) UIColor *bgColor; 16 | 17 | @property (nonatomic, assign) CGFloat cornerRadius; 18 | 19 | @property (nonatomic, strong) UIFont *font; 20 | 21 | //上下左右的缝隙 22 | @property (nonatomic) CGFloat inset; 23 | 24 | @property (nonatomic, strong) id target; 25 | 26 | @property (nonatomic) SEL action; 27 | 28 | - (instancetype)initWithText:(NSString *)text; 29 | 30 | + (instancetype)tagWithText:(NSString *)text; 31 | 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /WrapViewWithAutolayoutTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | weifu.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | **Copyright (c) 2012-2013 Matt Diephouse** 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /SFTagView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "SFTagView" 3 | s.version = "0.8" 4 | s.summary = "SFTagView is a powerful UIView subclass" 5 | 6 | s.description = <<-DESC 7 | SFTagView is a view for display tags 8 | - flexible layout, dynamic view height 9 | - support depends autolayout constraints to get SFTagView's width, It's useful 10 | - support specify set view's width of frame 11 | 12 | DESC 13 | 14 | s.homepage = "http://github.com/shiweifu/SFTagView" 15 | s.license = "MIT" 16 | 17 | s.author = { "shiweifu" => "shiweifu@gmail.com" } 18 | 19 | s.ios.deployment_target = "7.0" 20 | s.source = { :git => "https://github.com/shiweifu/SFTagView.git", :tag => "0.8" } 21 | 22 | s.source_files = "WrapViewWithAutolayout/*.{h,m}" 23 | s.exclude_files = "WrapViewWithAutolayout/AppDelegate.{h,m}", "WrapViewWithAutolayout/ViewController.{h,m}", "WrapViewWithAutolayout/main.m" 24 | s.framework = "UIKit", "Foundation" 25 | 26 | s.requires_arc = true 27 | 28 | 29 | end 30 | -------------------------------------------------------------------------------- /WrapViewWithAutolayoutTests/WrapViewWithAutolayoutTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WrapViewWithAutolayoutTests.m 3 | // WrapViewWithAutolayoutTests 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface WrapViewWithAutolayoutTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation WrapViewWithAutolayoutTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [DEPRECATED] 2 | [use https://github.com/shiweifu/DPTagView for insteaded.] 3 | 4 | 使用 View 实现的 Tag视图,不用再使用CollectionView 5 | 6 | 时过境迁,因为性能和复用性的考虑,本库去掉使用AutoLayout来实现,如果你想使用AutoLayout版,可以使用这个:[https://github.com/zsk425/SKTagView](https://github.com/zsk425/SKTagView) 7 | 8 | 9 | ###使用说明 10 | 11 | ```objc 12 | - (void)setupTagView 13 | { 14 | 15 | NSArray *texts = @[ @"A", @"Short", @"Button", @"Longer Button", @"Very Long Button", @"Short", @"More Button", @"Any Key"]; 16 | 17 | [texts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) 18 | { 19 | SFTag *tag = [SFTag tagWithText:obj]; 20 | tag.textColor = [UIColor blackColor]; 21 | tag.bgColor = [UIColor yellowColor]; 22 | 23 | [self.tagView addTag:tag]; 24 | }]; 25 | 26 | [self.view addSubview:self.tagView]; 27 | 28 | [self.tagView autoCenterInSuperview]; 29 | 30 | [self.tagView autoSetDimension:ALDimensionWidth toSize:220]; 31 | } 32 | ``` 33 | 34 | 详情见图: 35 | 36 | ![预览图][1] 37 | 38 | ![预览图][2] 39 | 40 | ![预览图][3] 41 | 42 | 43 | [1]: http://i3.tietuku.com/f55315bbb964ce21.jpg 44 | [2]: https://github.com/YiQieSuiYuan/SFTagView/blob/master/SFTagView-1.png 45 | [3]: https://github.com/YiQieSuiYuan/SFTagView/blob/master/SFTagView-2.png 46 | 47 | 48 | Swift 正在更新中 49 | 50 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | weifu.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/NSString+ObjectiveSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+ObjectiveSugar.h 3 | // SampleProject 4 | // 5 | // Created by Neil on 05/12/2012. 6 | // Copyright (c) 2012 @mneorr | mneorr.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NSString *NSStringWithFormat(NSString *format, ...) NS_FORMAT_FUNCTION(1,2); 12 | 13 | @interface NSString(ObjectiveSugar) 14 | 15 | /** 16 | Returns an array containing substrings from the receiver that have been divided by a whitespace delimiter 17 | 18 | @return An array containing substrings that have been divided by a whitespace delimiter 19 | */ 20 | - (NSArray *)split; 21 | 22 | 23 | /** 24 | Returns an array containing substrings from the receiver that have been divided by a given delimiter 25 | 26 | @param delimiter The delimiter string 27 | @return An array containing substrings that have been divided by delimiter 28 | */ 29 | - (NSArray *)split:(NSString *)delimiter; 30 | 31 | 32 | /** 33 | Returns a new string made by converting a snake_case_string to CamelCaseString 34 | 35 | @return A string made by converting a snake_case_string to CamelCaseString 36 | */ 37 | - (NSString *)camelCase; 38 | 39 | 40 | /** 41 | Returns a Boolean value that indicates whether a given string is a substring of the receiver 42 | 43 | @return YES if 'string' is a substring of the receiver, otherwise NO 44 | */ 45 | - (BOOL)containsString:(NSString *)string; 46 | 47 | 48 | /** 49 | Returns a new string made by removing whitespaces and newlines from both ends of the receiver 50 | 51 | @return A string without trailing or leading whitespaces and newlines 52 | */ 53 | - (NSString *)strip; 54 | 55 | @end 56 | 57 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/NSString+ObjectiveSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+ObjectiveSugar.m 3 | // SampleProject 4 | // 5 | // Created by Neil on 05/12/2012. 6 | // Copyright (c) 2012 @mneorr | mneorr.com. All rights reserved. 7 | // 8 | 9 | #import "NSString+ObjectiveSugar.h" 10 | 11 | static NSString *const UNDERSCORE = @"_"; 12 | static NSString *const SPACE = @" "; 13 | static NSString *const EMPTY_STRING = @""; 14 | 15 | NSString *NSStringWithFormat(NSString *formatString, ...) { 16 | va_list args; 17 | va_start(args, formatString); 18 | 19 | NSString *string = [[NSString alloc] initWithFormat:formatString arguments:args]; 20 | 21 | va_end(args); 22 | 23 | #if defined(__has_feature) && __has_feature(objc_arc) 24 | return string; 25 | #else 26 | return [string autorelease]; 27 | #endif 28 | } 29 | 30 | 31 | @implementation NSString(Additions) 32 | 33 | //- (NSArray *)split { 34 | // NSArray *result = [self componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 35 | // return [result select:^BOOL(NSString *string) { 36 | // return string.length > 0; 37 | // }]; 38 | //} 39 | 40 | - (NSArray *)split:(NSString *)delimiter { 41 | return [self componentsSeparatedByString:delimiter]; 42 | } 43 | 44 | - (NSString *)camelCase { 45 | NSString *spaced = [self stringByReplacingOccurrencesOfString:UNDERSCORE withString:SPACE]; 46 | NSString *capitalized = [spaced capitalizedString]; 47 | 48 | return [capitalized stringByReplacingOccurrencesOfString:SPACE withString:EMPTY_STRING]; 49 | } 50 | 51 | - (BOOL)containsString:(NSString *) string { 52 | NSRange range = [self rangeOfString:string options:NSCaseInsensitiveSearch]; 53 | return range.location != NSNotFound; 54 | } 55 | 56 | - (NSString *)strip { 57 | return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WrapViewWithAutolayout 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @property (nonatomic, strong) UIViewController *mainController; 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application { 20 | // 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. 21 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 22 | } 23 | 24 | - (void)applicationDidEnterBackground:(UIApplication *)application { 25 | // 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. 26 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 27 | } 28 | 29 | - (void)applicationWillEnterForeground:(UIApplication *)application { 30 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 31 | } 32 | 33 | - (void)applicationDidBecomeActive:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationWillTerminate:(UIApplication *)application { 38 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WrapViewWithAutolayout 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SFTag.h" 11 | #import "SFTagView.h" 12 | 13 | @interface ViewController () 14 | @property (strong, nonatomic) SFTagView *tagView; 15 | 16 | @property (nonatomic, strong) UIView *testView; 17 | @property (weak, nonatomic) IBOutlet UITextField *textField; 18 | 19 | 20 | @end 21 | 22 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 23 | 24 | @implementation ViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | // Do any additional setup after loading the view, typically from a nib. 29 | [self.view setBackgroundColor:[UIColor whiteColor]]; 30 | 31 | [self setupTagView]; 32 | [self setupData]; 33 | 34 | SFTagView *v = [[SFTagView alloc] initWithFrame:CGRectMake(0, 0, 320, 0)]; 35 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 36 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 37 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 38 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 39 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 40 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 41 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 42 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 43 | [v addTag:[[SFTag alloc] initWithText:@"hello"]]; 44 | 45 | NSLog(@"tagView frame: %@", NSStringFromCGRect(v.frame)); 46 | } 47 | 48 | - (void)setupTagView 49 | { 50 | [self.view addSubview:self.tagView]; 51 | } 52 | 53 | - (void)handleBtn:(UIButton *)btn 54 | { 55 | NSLog(@"%@", btn.titleLabel.text); 56 | } 57 | 58 | - (void)didReceiveMemoryWarning { 59 | [super didReceiveMemoryWarning]; 60 | // Dispose of any resources that can be recreated. 61 | } 62 | 63 | - (SFTagView *)tagView 64 | { 65 | if(!_tagView) 66 | { 67 | _tagView = [[SFTagView alloc] initWithFrame:CGRectMake(0, 20, 320, 0)]; 68 | [_tagView setBackgroundColor:[UIColor blueColor]]; 69 | 70 | // alignment 0 左对齐布局 1 右对齐布局 71 | _tagView.alignment = 1; 72 | 73 | _tagView.margin = UIEdgeInsetsMake(10, 3, 10, 3); 74 | _tagView.insets = 20; 75 | _tagView.lineSpace = 5; 76 | } 77 | 78 | return _tagView; 79 | } 80 | 81 | - (void)viewDidLayoutSubviews 82 | { 83 | [super viewDidLayoutSubviews]; 84 | } 85 | 86 | - (void)setupData 87 | { 88 | NSArray *texts = @[@"python", @"mysql", @"flask", @"django", @"bottle", @"webpy", @"php"]; 89 | 90 | [texts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) 91 | { 92 | SFTag *tag = [SFTag tagWithText:obj]; 93 | tag.textColor = [UIColor tagTextColor]; 94 | tag.bgColor = [UIColor tagBgColor]; 95 | tag.target = self; 96 | tag.action = @selector(handleBtn:); 97 | tag.cornerRadius = 3; 98 | 99 | [self.tagView addTag:tag]; 100 | }]; 101 | } 102 | 103 | - (IBAction)handleAddTag:(id)sender 104 | { 105 | if([self.textField.text isEqualToString:@"!"] ) 106 | { 107 | [self.tagView removeAllTags]; 108 | } 109 | 110 | SFTag *tag = [SFTag tagWithText:self.textField.text]; 111 | tag.textColor = [UIColor tagTextColor]; 112 | tag.bgColor = [UIColor tagBgColor]; 113 | tag.target = self; 114 | tag.action = @selector(handleBtn:); 115 | tag.cornerRadius = 3; 116 | 117 | NSUInteger fontSize = arc4random() % 30; 118 | 119 | tag.font = [UIFont systemFontOfSize:fontSize]; 120 | tag.inset = 10; 121 | 122 | [self.tagView addTag:tag]; 123 | NSLog(@"tagView frame: %@", NSStringFromCGRect(self.tagView.frame)); 124 | } 125 | @end 126 | 127 | @implementation UIColor(Test) 128 | 129 | + (UIColor *)tagBgColor 130 | { 131 | return [UIColor brownColor]; 132 | } 133 | 134 | + (UIColor *)tagTextColor 135 | { 136 | return [UIColor whiteColor]; 137 | } 138 | 139 | @end 140 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout/SFTagView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SFTagView.m 3 | // WrapViewWithAutolayout 4 | // 5 | // Created by shiweifu on 12/9/14. 6 | // Copyright (c) 2014 shiweifu. All rights reserved. 7 | // 8 | 9 | #import "SFTagView.h" 10 | #import "SFTag.h" 11 | #import "SFTagButton.h" 12 | 13 | @interface SFTagView () 14 | 15 | @property (nonatomic, strong) NSMutableArray *tags; 16 | @property (assign) CGFloat intrinsicHeight; 17 | 18 | @end 19 | 20 | @implementation SFTagView 21 | { 22 | } 23 | 24 | -(CGSize)intrinsicContentSize { 25 | return CGSizeMake(self.frame.size.width, self.intrinsicHeight); 26 | } 27 | 28 | - (void)addTag:(SFTag *)tag 29 | { 30 | SFTagButton *btn = [[SFTagButton alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; 31 | [btn setTitle:tag.text forState:UIControlStateNormal]; 32 | [btn.titleLabel setFont:tag.font]; 33 | [btn setBackgroundColor:tag.bgColor]; 34 | [btn setTitleColor:tag.textColor forState:UIControlStateNormal]; 35 | [btn addTarget:tag.target action:tag.action forControlEvents:UIControlEventTouchUpInside]; 36 | 37 | 38 | CGSize size; 39 | CGSize constraintSize = CGSizeMake(MAXFLOAT, MAXFLOAT); 40 | #ifdef __IPHONE_7_0 41 | NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 42 | [paragraphStyle setAlignment:NSTextAlignmentLeft]; 43 | [paragraphStyle setLineBreakMode:NSLineBreakByCharWrapping]; 44 | 45 | NSDictionary* stringAttributes = @{NSFontAttributeName: tag.font, 46 | NSParagraphStyleAttributeName: paragraphStyle}; 47 | size = [tag.text boundingRectWithSize: constraintSize 48 | options: NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading 49 | attributes: stringAttributes 50 | context: nil].size; 51 | #else 52 | size = [tag.text sizeWithFont: tag.font 53 | constrainedToSize: constraintSize 54 | lineBreakMode: NSLineBreakByCharWrapping]; 55 | #endif 56 | 57 | CGFloat i = tag.inset; 58 | if(i == 0) 59 | { 60 | i = 5; 61 | } 62 | size.width += i * 2; 63 | size.height += i * 2; 64 | 65 | btn.layer.cornerRadius = tag.cornerRadius; 66 | [btn.layer setMasksToBounds:YES]; 67 | 68 | // CGSize size = btn.intrinsicContentSize; 69 | CGRect r = CGRectMake(0, 0, size.width, size.height); 70 | [btn setFrame:r]; 71 | 72 | [self.tags addObject:btn]; 73 | 74 | [self rearrangeTags]; 75 | } 76 | 77 | #pragma mark - Tag removal 78 | 79 | - (void)removeTagText:(NSString *)text 80 | { 81 | SFTagButton *b = nil; 82 | for (SFTagButton *t in self.tags) { 83 | if([text isEqualToString:t.titleLabel.text]) 84 | { 85 | b = t; 86 | } 87 | } 88 | 89 | if(!b) 90 | { 91 | return; 92 | } 93 | 94 | [b removeFromSuperview]; 95 | [self.tags removeObject:b]; 96 | [self rearrangeTags]; 97 | } 98 | 99 | - (void)removeAllTags 100 | { 101 | for (SFTagButton *t in self.tags) { 102 | [t removeFromSuperview]; 103 | } 104 | [self.tags removeAllObjects]; 105 | [self rearrangeTags]; 106 | } 107 | 108 | - (void)rearrangeTags 109 | { 110 | // 左对齐布局 111 | if (self.alignment == 0) 112 | { 113 | [self.subviews enumerateObjectsUsingBlock:^(UIView* obj, NSUInteger idx, BOOL *stop) { 114 | [obj removeFromSuperview]; 115 | }]; 116 | __block float maxY = self.margin.top; 117 | __block float maxX = self.margin.left; 118 | __block CGSize size; 119 | [self.tags enumerateObjectsUsingBlock:^(SFTagButton *obj, NSUInteger idx, BOOL *stop) { 120 | size = obj.frame.size; 121 | [self.subviews enumerateObjectsUsingBlock:^(UIView* obj, NSUInteger idx, BOOL *stop) { 122 | if ([obj isKindOfClass:[SFTagButton class]]) { 123 | maxY = MAX(maxY, obj.frame.origin.y); 124 | } 125 | }]; 126 | 127 | [self.subviews enumerateObjectsUsingBlock:^(SFTagButton *obj, NSUInteger idx, BOOL *stop) { 128 | if ([obj isKindOfClass:[SFTagButton class]]) { 129 | if (obj.frame.origin.y == maxY) { 130 | maxX = MAX(maxX, obj.frame.origin.x + obj.frame.size.width); 131 | } 132 | } 133 | }]; 134 | 135 | // Go to a new line if the tag won't fit 136 | if (size.width + maxX + self.insets > (self.frame.size.width - self.margin.right)) { 137 | maxY += size.height + self.lineSpace; 138 | maxX = self.margin.left; 139 | } 140 | obj.frame = (CGRect){maxX + self.insets, maxY, size.width, size.height}; 141 | [self addSubview:obj]; 142 | }]; 143 | 144 | CGRect r = self.frame; 145 | CGFloat n = maxY + size.height + self.margin.bottom; 146 | self.intrinsicHeight = n > self.intrinsicHeight? n : self.intrinsicHeight; 147 | [self setFrame:CGRectMake(r.origin.x, r.origin.y, self.frame.size.width, self.intrinsicHeight)]; 148 | } 149 | // 右对齐布局 150 | else 151 | { 152 | [self.subviews enumerateObjectsUsingBlock:^(UIView* obj, NSUInteger idx, BOOL *stop) { 153 | [obj removeFromSuperview]; 154 | }]; 155 | __block float maxY = self.margin.top; 156 | __block float maxX = self.margin.left; 157 | __block CGSize size; 158 | [self.tags enumerateObjectsUsingBlock:^(SFTagButton *obj, NSUInteger idx, BOOL *stop) { 159 | size = obj.frame.size; 160 | [self.subviews enumerateObjectsUsingBlock:^(UIView* obj, NSUInteger idx, BOOL *stop) { 161 | if ([obj isKindOfClass:[SFTagButton class]]) { 162 | maxY = MAX(maxY, obj.frame.origin.y); 163 | } 164 | }]; 165 | 166 | [self.subviews enumerateObjectsUsingBlock:^(SFTagButton *obj, NSUInteger idx, BOOL *stop) { 167 | if ([obj isKindOfClass:[SFTagButton class]]) { 168 | if (obj.frame.origin.y == maxY) { 169 | maxX = MAX(maxX, self.frame.size.width-obj.frame.origin.x); 170 | } 171 | } 172 | }]; 173 | 174 | // Go to a new line if the tag won't fit 175 | if (size.width + maxX + self.insets > (self.frame.size.width - self.margin.right)) { 176 | maxY += size.height + self.lineSpace; 177 | maxX = self.margin.left; 178 | } 179 | obj.frame = (CGRect){self.frame.size.width - obj.frame.size.width - maxX - self.insets, maxY, size.width, size.height}; 180 | [self addSubview:obj]; 181 | NSLog(@"%@---%@",@(self.frame.size.width - obj.frame.size.width - maxX - self.insets),@(maxX)); 182 | }]; 183 | 184 | CGRect r = self.frame; 185 | CGFloat n = maxY + size.height + self.margin.bottom; 186 | self.intrinsicHeight = n > self.intrinsicHeight? n : self.intrinsicHeight; 187 | [self setFrame:CGRectMake(r.origin.x, r.origin.y, self.frame.size.width, self.intrinsicHeight)]; 188 | } 189 | } 190 | - (void)layoutSubviews 191 | { 192 | [super layoutSubviews]; 193 | [self rearrangeTags]; 194 | } 195 | 196 | - (NSMutableArray *)tags 197 | { 198 | if(!_tags) 199 | { 200 | _tags = [NSMutableArray array]; 201 | } 202 | return _tags; 203 | } 204 | 205 | @end 206 | -------------------------------------------------------------------------------- /WrapViewWithAutolayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 682ABA701A36933300D57A1A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA6F1A36933300D57A1A /* main.m */; }; 11 | 682ABA731A36933300D57A1A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA721A36933300D57A1A /* AppDelegate.m */; }; 12 | 682ABA761A36933300D57A1A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA751A36933300D57A1A /* ViewController.m */; }; 13 | 682ABA791A36933300D57A1A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 682ABA771A36933300D57A1A /* Main.storyboard */; }; 14 | 682ABA7B1A36933300D57A1A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 682ABA7A1A36933300D57A1A /* Images.xcassets */; }; 15 | 682ABA7E1A36933300D57A1A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 682ABA7C1A36933300D57A1A /* LaunchScreen.xib */; }; 16 | 682ABA8A1A36933300D57A1A /* WrapViewWithAutolayoutTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA891A36933300D57A1A /* WrapViewWithAutolayoutTests.m */; }; 17 | 682ABA951A3693BC00D57A1A /* SFTagView.m in Sources */ = {isa = PBXBuildFile; fileRef = 682ABA941A3693BC00D57A1A /* SFTagView.m */; }; 18 | E198833B70106A7B969AF9D2 /* SFTag.m in Sources */ = {isa = PBXBuildFile; fileRef = E198883D944B29B6488A5B34 /* SFTag.m */; }; 19 | E1988E0CF76D59E86E94A7CC /* SFTagButton.m in Sources */ = {isa = PBXBuildFile; fileRef = E1988DC652E4B5A7DD3FC44D /* SFTagButton.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 682ABA841A36933300D57A1A /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 682ABA621A36933300D57A1A /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 682ABA691A36933300D57A1A; 28 | remoteInfo = WrapViewWithAutolayout; 29 | }; 30 | /* End PBXContainerItemProxy section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 29C057F90EEE2D90403FAC89 /* Pods-WrapViewWithAutolayout.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WrapViewWithAutolayout.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WrapViewWithAutolayout/Pods-WrapViewWithAutolayout.debug.xcconfig"; sourceTree = ""; }; 34 | 682ABA6A1A36933300D57A1A /* WrapViewWithAutolayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WrapViewWithAutolayout.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 682ABA6E1A36933300D57A1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 682ABA6F1A36933300D57A1A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | 682ABA711A36933300D57A1A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 682ABA721A36933300D57A1A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 682ABA741A36933300D57A1A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 40 | 682ABA751A36933300D57A1A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 41 | 682ABA781A36933300D57A1A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 682ABA7A1A36933300D57A1A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 43 | 682ABA7D1A36933300D57A1A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 44 | 682ABA831A36933300D57A1A /* WrapViewWithAutolayoutTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WrapViewWithAutolayoutTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 682ABA881A36933300D57A1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 682ABA891A36933300D57A1A /* WrapViewWithAutolayoutTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WrapViewWithAutolayoutTests.m; sourceTree = ""; }; 47 | 682ABA931A3693BC00D57A1A /* SFTagView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFTagView.h; sourceTree = ""; }; 48 | 682ABA941A3693BC00D57A1A /* SFTagView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFTagView.m; sourceTree = ""; }; 49 | 6B8DAFE5AC7C5EAB149408DB /* Pods-WrapViewWithAutolayout.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WrapViewWithAutolayout.release.xcconfig"; path = "Pods/Target Support Files/Pods-WrapViewWithAutolayout/Pods-WrapViewWithAutolayout.release.xcconfig"; sourceTree = ""; }; 50 | E19884C2F2577114719748BD /* SFTagButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFTagButton.h; sourceTree = ""; }; 51 | E198883D944B29B6488A5B34 /* SFTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFTag.m; sourceTree = ""; }; 52 | E1988A206257CAF7FE6FC77A /* SFTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFTag.h; sourceTree = ""; }; 53 | E1988DC652E4B5A7DD3FC44D /* SFTagButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFTagButton.m; sourceTree = ""; }; 54 | E9C06A50A78EFF632557FD24 /* libPods-WrapViewWithAutolayout.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-WrapViewWithAutolayout.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 682ABA671A36933300D57A1A /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | 682ABA801A36933300D57A1A /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | 682ABA611A36933300D57A1A = { 76 | isa = PBXGroup; 77 | children = ( 78 | 682ABA6C1A36933300D57A1A /* WrapViewWithAutolayout */, 79 | 682ABA861A36933300D57A1A /* WrapViewWithAutolayoutTests */, 80 | 682ABA6B1A36933300D57A1A /* Products */, 81 | 8E977D293B7744A3F0911ED5 /* Pods */, 82 | E9B8B9417B704821F5FF7698 /* Frameworks */, 83 | ); 84 | sourceTree = ""; 85 | }; 86 | 682ABA6B1A36933300D57A1A /* Products */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 682ABA6A1A36933300D57A1A /* WrapViewWithAutolayout.app */, 90 | 682ABA831A36933300D57A1A /* WrapViewWithAutolayoutTests.xctest */, 91 | ); 92 | name = Products; 93 | sourceTree = ""; 94 | }; 95 | 682ABA6C1A36933300D57A1A /* WrapViewWithAutolayout */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 682ABA711A36933300D57A1A /* AppDelegate.h */, 99 | 682ABA721A36933300D57A1A /* AppDelegate.m */, 100 | 682ABA741A36933300D57A1A /* ViewController.h */, 101 | 682ABA751A36933300D57A1A /* ViewController.m */, 102 | 682ABA771A36933300D57A1A /* Main.storyboard */, 103 | 682ABA931A3693BC00D57A1A /* SFTagView.h */, 104 | 682ABA941A3693BC00D57A1A /* SFTagView.m */, 105 | 682ABA7A1A36933300D57A1A /* Images.xcassets */, 106 | 682ABA7C1A36933300D57A1A /* LaunchScreen.xib */, 107 | 682ABA6D1A36933300D57A1A /* Supporting Files */, 108 | E198883D944B29B6488A5B34 /* SFTag.m */, 109 | E1988A206257CAF7FE6FC77A /* SFTag.h */, 110 | E1988DC652E4B5A7DD3FC44D /* SFTagButton.m */, 111 | E19884C2F2577114719748BD /* SFTagButton.h */, 112 | ); 113 | path = WrapViewWithAutolayout; 114 | sourceTree = ""; 115 | }; 116 | 682ABA6D1A36933300D57A1A /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 682ABA6E1A36933300D57A1A /* Info.plist */, 120 | 682ABA6F1A36933300D57A1A /* main.m */, 121 | ); 122 | name = "Supporting Files"; 123 | sourceTree = ""; 124 | }; 125 | 682ABA861A36933300D57A1A /* WrapViewWithAutolayoutTests */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 682ABA891A36933300D57A1A /* WrapViewWithAutolayoutTests.m */, 129 | 682ABA871A36933300D57A1A /* Supporting Files */, 130 | ); 131 | path = WrapViewWithAutolayoutTests; 132 | sourceTree = ""; 133 | }; 134 | 682ABA871A36933300D57A1A /* Supporting Files */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 682ABA881A36933300D57A1A /* Info.plist */, 138 | ); 139 | name = "Supporting Files"; 140 | sourceTree = ""; 141 | }; 142 | 8E977D293B7744A3F0911ED5 /* Pods */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 29C057F90EEE2D90403FAC89 /* Pods-WrapViewWithAutolayout.debug.xcconfig */, 146 | 6B8DAFE5AC7C5EAB149408DB /* Pods-WrapViewWithAutolayout.release.xcconfig */, 147 | ); 148 | name = Pods; 149 | sourceTree = ""; 150 | }; 151 | E9B8B9417B704821F5FF7698 /* Frameworks */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | E9C06A50A78EFF632557FD24 /* libPods-WrapViewWithAutolayout.a */, 155 | ); 156 | name = Frameworks; 157 | sourceTree = ""; 158 | }; 159 | /* End PBXGroup section */ 160 | 161 | /* Begin PBXNativeTarget section */ 162 | 682ABA691A36933300D57A1A /* WrapViewWithAutolayout */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 682ABA8D1A36933300D57A1A /* Build configuration list for PBXNativeTarget "WrapViewWithAutolayout" */; 165 | buildPhases = ( 166 | 56A572FD8CB365055FBC8C48 /* Check Pods Manifest.lock */, 167 | 682ABA661A36933300D57A1A /* Sources */, 168 | 682ABA671A36933300D57A1A /* Frameworks */, 169 | 682ABA681A36933300D57A1A /* Resources */, 170 | FAE40ECF28B915D0419B9B28 /* Copy Pods Resources */, 171 | ); 172 | buildRules = ( 173 | ); 174 | dependencies = ( 175 | ); 176 | name = WrapViewWithAutolayout; 177 | productName = WrapViewWithAutolayout; 178 | productReference = 682ABA6A1A36933300D57A1A /* WrapViewWithAutolayout.app */; 179 | productType = "com.apple.product-type.application"; 180 | }; 181 | 682ABA821A36933300D57A1A /* WrapViewWithAutolayoutTests */ = { 182 | isa = PBXNativeTarget; 183 | buildConfigurationList = 682ABA901A36933300D57A1A /* Build configuration list for PBXNativeTarget "WrapViewWithAutolayoutTests" */; 184 | buildPhases = ( 185 | 682ABA7F1A36933300D57A1A /* Sources */, 186 | 682ABA801A36933300D57A1A /* Frameworks */, 187 | 682ABA811A36933300D57A1A /* Resources */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | 682ABA851A36933300D57A1A /* PBXTargetDependency */, 193 | ); 194 | name = WrapViewWithAutolayoutTests; 195 | productName = WrapViewWithAutolayoutTests; 196 | productReference = 682ABA831A36933300D57A1A /* WrapViewWithAutolayoutTests.xctest */; 197 | productType = "com.apple.product-type.bundle.unit-test"; 198 | }; 199 | /* End PBXNativeTarget section */ 200 | 201 | /* Begin PBXProject section */ 202 | 682ABA621A36933300D57A1A /* Project object */ = { 203 | isa = PBXProject; 204 | attributes = { 205 | LastUpgradeCheck = 0600; 206 | ORGANIZATIONNAME = shiweifu; 207 | TargetAttributes = { 208 | 682ABA691A36933300D57A1A = { 209 | CreatedOnToolsVersion = 6.0; 210 | }; 211 | 682ABA821A36933300D57A1A = { 212 | CreatedOnToolsVersion = 6.0; 213 | TestTargetID = 682ABA691A36933300D57A1A; 214 | }; 215 | }; 216 | }; 217 | buildConfigurationList = 682ABA651A36933300D57A1A /* Build configuration list for PBXProject "WrapViewWithAutolayout" */; 218 | compatibilityVersion = "Xcode 3.2"; 219 | developmentRegion = English; 220 | hasScannedForEncodings = 0; 221 | knownRegions = ( 222 | en, 223 | Base, 224 | ); 225 | mainGroup = 682ABA611A36933300D57A1A; 226 | productRefGroup = 682ABA6B1A36933300D57A1A /* Products */; 227 | projectDirPath = ""; 228 | projectRoot = ""; 229 | targets = ( 230 | 682ABA691A36933300D57A1A /* WrapViewWithAutolayout */, 231 | 682ABA821A36933300D57A1A /* WrapViewWithAutolayoutTests */, 232 | ); 233 | }; 234 | /* End PBXProject section */ 235 | 236 | /* Begin PBXResourcesBuildPhase section */ 237 | 682ABA681A36933300D57A1A /* Resources */ = { 238 | isa = PBXResourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | 682ABA791A36933300D57A1A /* Main.storyboard in Resources */, 242 | 682ABA7E1A36933300D57A1A /* LaunchScreen.xib in Resources */, 243 | 682ABA7B1A36933300D57A1A /* Images.xcassets in Resources */, 244 | ); 245 | runOnlyForDeploymentPostprocessing = 0; 246 | }; 247 | 682ABA811A36933300D57A1A /* Resources */ = { 248 | isa = PBXResourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | /* End PBXResourcesBuildPhase section */ 255 | 256 | /* Begin PBXShellScriptBuildPhase section */ 257 | 56A572FD8CB365055FBC8C48 /* Check Pods Manifest.lock */ = { 258 | isa = PBXShellScriptBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | inputPaths = ( 263 | ); 264 | name = "Check Pods Manifest.lock"; 265 | outputPaths = ( 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | shellPath = /bin/sh; 269 | shellScript = ""; 270 | showEnvVarsInLog = 0; 271 | }; 272 | FAE40ECF28B915D0419B9B28 /* Copy Pods Resources */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputPaths = ( 278 | ); 279 | name = "Copy Pods Resources"; 280 | outputPaths = ( 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | shellPath = /bin/sh; 284 | shellScript = ""; 285 | showEnvVarsInLog = 0; 286 | }; 287 | /* End PBXShellScriptBuildPhase section */ 288 | 289 | /* Begin PBXSourcesBuildPhase section */ 290 | 682ABA661A36933300D57A1A /* Sources */ = { 291 | isa = PBXSourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | 682ABA761A36933300D57A1A /* ViewController.m in Sources */, 295 | 682ABA731A36933300D57A1A /* AppDelegate.m in Sources */, 296 | 682ABA951A3693BC00D57A1A /* SFTagView.m in Sources */, 297 | 682ABA701A36933300D57A1A /* main.m in Sources */, 298 | E198833B70106A7B969AF9D2 /* SFTag.m in Sources */, 299 | E1988E0CF76D59E86E94A7CC /* SFTagButton.m in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | 682ABA7F1A36933300D57A1A /* Sources */ = { 304 | isa = PBXSourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | 682ABA8A1A36933300D57A1A /* WrapViewWithAutolayoutTests.m in Sources */, 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | /* End PBXSourcesBuildPhase section */ 312 | 313 | /* Begin PBXTargetDependency section */ 314 | 682ABA851A36933300D57A1A /* PBXTargetDependency */ = { 315 | isa = PBXTargetDependency; 316 | target = 682ABA691A36933300D57A1A /* WrapViewWithAutolayout */; 317 | targetProxy = 682ABA841A36933300D57A1A /* PBXContainerItemProxy */; 318 | }; 319 | /* End PBXTargetDependency section */ 320 | 321 | /* Begin PBXVariantGroup section */ 322 | 682ABA771A36933300D57A1A /* Main.storyboard */ = { 323 | isa = PBXVariantGroup; 324 | children = ( 325 | 682ABA781A36933300D57A1A /* Base */, 326 | ); 327 | name = Main.storyboard; 328 | sourceTree = ""; 329 | }; 330 | 682ABA7C1A36933300D57A1A /* LaunchScreen.xib */ = { 331 | isa = PBXVariantGroup; 332 | children = ( 333 | 682ABA7D1A36933300D57A1A /* Base */, 334 | ); 335 | name = LaunchScreen.xib; 336 | sourceTree = ""; 337 | }; 338 | /* End PBXVariantGroup section */ 339 | 340 | /* Begin XCBuildConfiguration section */ 341 | 682ABA8B1A36933300D57A1A /* Debug */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ALWAYS_SEARCH_USER_PATHS = NO; 345 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 346 | CLANG_CXX_LIBRARY = "libc++"; 347 | CLANG_ENABLE_MODULES = YES; 348 | CLANG_ENABLE_OBJC_ARC = YES; 349 | CLANG_WARN_BOOL_CONVERSION = YES; 350 | CLANG_WARN_CONSTANT_CONVERSION = YES; 351 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 352 | CLANG_WARN_EMPTY_BODY = YES; 353 | CLANG_WARN_ENUM_CONVERSION = YES; 354 | CLANG_WARN_INT_CONVERSION = YES; 355 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 356 | CLANG_WARN_UNREACHABLE_CODE = YES; 357 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 358 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 359 | COPY_PHASE_STRIP = NO; 360 | ENABLE_STRICT_OBJC_MSGSEND = YES; 361 | GCC_C_LANGUAGE_STANDARD = gnu99; 362 | GCC_DYNAMIC_NO_PIC = NO; 363 | GCC_OPTIMIZATION_LEVEL = 0; 364 | GCC_PREPROCESSOR_DEFINITIONS = ( 365 | "DEBUG=1", 366 | "$(inherited)", 367 | ); 368 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 376 | MTL_ENABLE_DEBUG_INFO = YES; 377 | ONLY_ACTIVE_ARCH = YES; 378 | SDKROOT = iphoneos; 379 | }; 380 | name = Debug; 381 | }; 382 | 682ABA8C1A36933300D57A1A /* Release */ = { 383 | isa = XCBuildConfiguration; 384 | buildSettings = { 385 | ALWAYS_SEARCH_USER_PATHS = NO; 386 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 387 | CLANG_CXX_LIBRARY = "libc++"; 388 | CLANG_ENABLE_MODULES = YES; 389 | CLANG_ENABLE_OBJC_ARC = YES; 390 | CLANG_WARN_BOOL_CONVERSION = YES; 391 | CLANG_WARN_CONSTANT_CONVERSION = YES; 392 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 393 | CLANG_WARN_EMPTY_BODY = YES; 394 | CLANG_WARN_ENUM_CONVERSION = YES; 395 | CLANG_WARN_INT_CONVERSION = YES; 396 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 397 | CLANG_WARN_UNREACHABLE_CODE = YES; 398 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 399 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 400 | COPY_PHASE_STRIP = YES; 401 | ENABLE_NS_ASSERTIONS = NO; 402 | ENABLE_STRICT_OBJC_MSGSEND = YES; 403 | GCC_C_LANGUAGE_STANDARD = gnu99; 404 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 405 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 406 | GCC_WARN_UNDECLARED_SELECTOR = YES; 407 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 408 | GCC_WARN_UNUSED_FUNCTION = YES; 409 | GCC_WARN_UNUSED_VARIABLE = YES; 410 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 411 | MTL_ENABLE_DEBUG_INFO = NO; 412 | SDKROOT = iphoneos; 413 | VALIDATE_PRODUCT = YES; 414 | }; 415 | name = Release; 416 | }; 417 | 682ABA8E1A36933300D57A1A /* Debug */ = { 418 | isa = XCBuildConfiguration; 419 | baseConfigurationReference = 29C057F90EEE2D90403FAC89 /* Pods-WrapViewWithAutolayout.debug.xcconfig */; 420 | buildSettings = { 421 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 422 | INFOPLIST_FILE = WrapViewWithAutolayout/Info.plist; 423 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 424 | PRODUCT_NAME = "$(TARGET_NAME)"; 425 | USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/Pods\"/**"; 426 | }; 427 | name = Debug; 428 | }; 429 | 682ABA8F1A36933300D57A1A /* Release */ = { 430 | isa = XCBuildConfiguration; 431 | baseConfigurationReference = 6B8DAFE5AC7C5EAB149408DB /* Pods-WrapViewWithAutolayout.release.xcconfig */; 432 | buildSettings = { 433 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 434 | INFOPLIST_FILE = WrapViewWithAutolayout/Info.plist; 435 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 436 | PRODUCT_NAME = "$(TARGET_NAME)"; 437 | USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/Pods\"/**"; 438 | }; 439 | name = Release; 440 | }; 441 | 682ABA911A36933300D57A1A /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | BUNDLE_LOADER = "$(TEST_HOST)"; 445 | FRAMEWORK_SEARCH_PATHS = ( 446 | "$(SDKROOT)/Developer/Library/Frameworks", 447 | "$(inherited)", 448 | ); 449 | GCC_PREPROCESSOR_DEFINITIONS = ( 450 | "DEBUG=1", 451 | "$(inherited)", 452 | ); 453 | INFOPLIST_FILE = WrapViewWithAutolayoutTests/Info.plist; 454 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WrapViewWithAutolayout.app/WrapViewWithAutolayout"; 457 | }; 458 | name = Debug; 459 | }; 460 | 682ABA921A36933300D57A1A /* Release */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | BUNDLE_LOADER = "$(TEST_HOST)"; 464 | FRAMEWORK_SEARCH_PATHS = ( 465 | "$(SDKROOT)/Developer/Library/Frameworks", 466 | "$(inherited)", 467 | ); 468 | INFOPLIST_FILE = WrapViewWithAutolayoutTests/Info.plist; 469 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 470 | PRODUCT_NAME = "$(TARGET_NAME)"; 471 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WrapViewWithAutolayout.app/WrapViewWithAutolayout"; 472 | }; 473 | name = Release; 474 | }; 475 | /* End XCBuildConfiguration section */ 476 | 477 | /* Begin XCConfigurationList section */ 478 | 682ABA651A36933300D57A1A /* Build configuration list for PBXProject "WrapViewWithAutolayout" */ = { 479 | isa = XCConfigurationList; 480 | buildConfigurations = ( 481 | 682ABA8B1A36933300D57A1A /* Debug */, 482 | 682ABA8C1A36933300D57A1A /* Release */, 483 | ); 484 | defaultConfigurationIsVisible = 0; 485 | defaultConfigurationName = Release; 486 | }; 487 | 682ABA8D1A36933300D57A1A /* Build configuration list for PBXNativeTarget "WrapViewWithAutolayout" */ = { 488 | isa = XCConfigurationList; 489 | buildConfigurations = ( 490 | 682ABA8E1A36933300D57A1A /* Debug */, 491 | 682ABA8F1A36933300D57A1A /* Release */, 492 | ); 493 | defaultConfigurationIsVisible = 0; 494 | defaultConfigurationName = Release; 495 | }; 496 | 682ABA901A36933300D57A1A /* Build configuration list for PBXNativeTarget "WrapViewWithAutolayoutTests" */ = { 497 | isa = XCConfigurationList; 498 | buildConfigurations = ( 499 | 682ABA911A36933300D57A1A /* Debug */, 500 | 682ABA921A36933300D57A1A /* Release */, 501 | ); 502 | defaultConfigurationIsVisible = 0; 503 | defaultConfigurationName = Release; 504 | }; 505 | /* End XCConfigurationList section */ 506 | }; 507 | rootObject = 682ABA621A36933300D57A1A /* Project object */; 508 | } 509 | --------------------------------------------------------------------------------