├── image.gif
├── README.md
├── CollectionViewSubscriptionLabel.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
├── xcuserdata
│ └── chenyk.xcuserdatad
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── CollectionViewSubscriptionLabel.xcscheme
└── project.pbxproj
├── CollectionViewSubscriptionLabel
├── ViewController.h
├── AppDelegate.h
├── CollectionViewCell.h
├── main.m
├── CollectionHeaderView.h
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── CollectionHeaderView.m
├── CollectionViewCell.m
├── Info.plist
├── Base.lproj
│ ├── Main.storyboard
│ └── LaunchScreen.xib
├── UICollectionViewLeftAlignedLayout
│ ├── UICollectionViewLeftAlignedLayout.h
│ └── UICollectionViewLeftAlignedLayout.m
├── AppDelegate.m
└── ViewController.m
└── CollectionViewSubscriptionLabelTests
├── Info.plist
└── CollectionViewSubscriptionLabelTests.m
/image.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenyk0317/CollectionViewSubscriptionLabel/HEAD/image.gif
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CollectionViewSubscriptionLabel
2 |
3 | CollectionView实现自选标签选择器
4 |
5 | 
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. 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 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 | @property (nonatomic, strong) UILabel * titleLabel;
13 |
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. 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 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/CollectionHeaderView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionHeaderView.h
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | extern float CYLFilterHeaderViewHeigt;
12 |
13 |
14 | @interface CollectionHeaderView : UICollectionReusableView
15 |
16 | @property (nonatomic,strong)UILabel * titleLabel;
17 |
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel.xcodeproj/xcuserdata/chenyk.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CollectionViewSubscriptionLabel.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E150BAB71AEA0DB0007D25B4
16 |
17 | primary
18 |
19 |
20 | E150BAD01AEA0DB0007D25B4
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/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 | }
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabelTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.juniorchina.$(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 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabelTests/CollectionViewSubscriptionLabelTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewSubscriptionLabelTests.m
3 | // CollectionViewSubscriptionLabelTests
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface CollectionViewSubscriptionLabelTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation CollectionViewSubscriptionLabelTests
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 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/CollectionHeaderView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionHeaderView.m
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. All rights reserved.
7 | //
8 |
9 | #import "CollectionHeaderView.h"
10 |
11 | #define kTitleButtonWidth 250.f
12 | #define kMoreButtonWidth 36*2
13 | #define kCureOfLineHight 0.5
14 | #define kCureOfLineOffX 16
15 |
16 | float CYLFilterHeaderViewHeigt = 38;
17 |
18 | @implementation CollectionHeaderView
19 | - (id)initWithFrame:(CGRect)frame
20 | {
21 | self = [super initWithFrame:frame];
22 | if (self) {
23 | self = [self sharedInit];
24 | }
25 | return self;
26 | }
27 | - (id)initWithCoder: (NSCoder *)aDecoder {
28 | self = [super initWithCoder: aDecoder];
29 | if (self) {
30 | self = [self sharedInit];
31 | }
32 | return self;
33 | }
34 |
35 | - (id)sharedInit {
36 | self.backgroundColor = [UIColor colorWithRed:188.0/255.0 green:188.0/255.0 blue:188.0/255.0 alpha:1.0];
37 | self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 30)];
38 | self.titleLabel.text = @"我的订阅";
39 | [self addSubview:self.titleLabel];
40 | return self;
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 |
11 | @implementation CollectionViewCell
12 | - (id)initWithFrame:(CGRect)frame
13 | {
14 | self = [super initWithFrame:frame];
15 | if (self) {
16 | [self setup];
17 | }
18 | return self;
19 | }
20 |
21 | - (id)initWithCoder: (NSCoder *)aDecoder {
22 | self = [super initWithCoder: aDecoder];
23 | if (self) {
24 | self = [self sharedInit];
25 | }
26 | return self;
27 | }
28 | - (id)sharedInit {
29 | [self setup];
30 | return self;
31 | }
32 |
33 | - (void)setup {
34 | self.titleLabel = [UILabel new];
35 | self.titleLabel.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
36 | self.titleLabel.textAlignment = NSTextAlignmentCenter;
37 | self.titleLabel.font = [UIFont systemFontOfSize:14];
38 |
39 | self.titleLabel.layer.cornerRadius = 5.0;
40 | self.titleLabel.backgroundColor = [UIColor whiteColor];
41 | self.titleLabel.layer.borderWidth = 1;
42 | self.titleLabel.layer.masksToBounds = YES;
43 |
44 | [self.contentView addSubview:self.titleLabel];
45 | }
46 |
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.juniorchina.$(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 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/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 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/UICollectionViewLeftAlignedLayout/UICollectionViewLeftAlignedLayout.h:
--------------------------------------------------------------------------------
1 |
2 | // Copyright (c) 2014 Giovanni Lodi
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
5 | // this software and associated documentation files (the "Software"), to deal in
6 | // the Software without restriction, including without limitation the rights to
7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 | // the Software, and to permit persons to whom the Software is furnished to do so,
9 | // subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all
12 | // copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 |
21 | /**
22 | * Simple UICollectionViewFlowLayout that aligns the cells to the left rather than justify them
23 | *
24 | * Based on http://stackoverflow.com/questions/13017257/how-do-you-determine-spacing-between-cells-in-uicollectionview-flowlayout
25 | */
26 |
27 | #import
28 |
29 | @interface UICollectionViewLeftAlignedLayout : UICollectionViewFlowLayout
30 |
31 | @end
32 |
33 | /**
34 | * Just a convenience protocol to keep things consistent.
35 | * Someone could find it confusing for a delegate object to conform to UICollectionViewDelegateFlowLayout
36 | * while using UICollectionViewLeftAlignedLayout.
37 | */
38 | @protocol UICollectionViewDelegateLeftAlignedLayout
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. 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 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // 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.
25 | // 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.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // 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.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // 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.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // 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.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/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 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel.xcodeproj/xcuserdata/chenyk.xcuserdatad/xcschemes/CollectionViewSubscriptionLabel.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/UICollectionViewLeftAlignedLayout/UICollectionViewLeftAlignedLayout.m:
--------------------------------------------------------------------------------
1 |
2 | // Copyright (c) 2014 Giovanni Lodi
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
5 | // this software and associated documentation files (the "Software"), to deal in
6 | // the Software without restriction, including without limitation the rights to
7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 | // the Software, and to permit persons to whom the Software is furnished to do so,
9 | // subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in all
12 | // copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 |
21 | #import "UICollectionViewLeftAlignedLayout.h"
22 |
23 | @interface UICollectionViewLayoutAttributes (LeftAligned)
24 |
25 | - (void)leftAlignFrameWithSectionInset:(UIEdgeInsets)sectionInset;
26 |
27 | @end
28 |
29 | @implementation UICollectionViewLayoutAttributes (LeftAligned)
30 |
31 | - (void)leftAlignFrameWithSectionInset:(UIEdgeInsets)sectionInset
32 | {
33 | CGRect frame = self.frame;
34 | frame.origin.x = sectionInset.left;
35 | self.frame = frame;
36 | }
37 |
38 | @end
39 |
40 | #pragma mark -
41 |
42 | @implementation UICollectionViewLeftAlignedLayout
43 |
44 | #pragma mark - UICollectionViewLayout
45 |
46 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
47 | NSArray* attributesToReturn = [super layoutAttributesForElementsInRect:rect];
48 | for (UICollectionViewLayoutAttributes* attributes in attributesToReturn) {
49 | if (nil == attributes.representedElementKind) {
50 | NSIndexPath* indexPath = attributes.indexPath;
51 | attributes.frame = [self layoutAttributesForItemAtIndexPath:indexPath].frame;
52 | }
53 | }
54 | return attributesToReturn;
55 | }
56 |
57 | - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
58 | UICollectionViewLayoutAttributes* currentItemAttributes = [super layoutAttributesForItemAtIndexPath:indexPath];
59 | UIEdgeInsets sectionInset = [self evaluatedSectionInsetForItemAtIndex:indexPath.section];
60 |
61 | BOOL isFirstItemInSection = indexPath.item == 0;
62 | CGFloat layoutWidth = CGRectGetWidth(self.collectionView.frame) - sectionInset.left - sectionInset.right;
63 |
64 | if (isFirstItemInSection) {
65 | [currentItemAttributes leftAlignFrameWithSectionInset:sectionInset];
66 | return currentItemAttributes;
67 | }
68 |
69 | NSIndexPath* previousIndexPath = [NSIndexPath indexPathForItem:indexPath.item-1 inSection:indexPath.section];
70 | CGRect previousFrame = [self layoutAttributesForItemAtIndexPath:previousIndexPath].frame;
71 | CGFloat previousFrameRightPoint = previousFrame.origin.x + previousFrame.size.width;
72 | CGRect currentFrame = currentItemAttributes.frame;
73 | CGRect strecthedCurrentFrame = CGRectMake(sectionInset.left,
74 | currentFrame.origin.y,
75 | layoutWidth,
76 | currentFrame.size.height);
77 | // if the current frame, once left aligned to the left and stretched to the full collection view
78 | // widht intersects the previous frame then they are on the same line
79 | BOOL isFirstItemInRow = !CGRectIntersectsRect(previousFrame, strecthedCurrentFrame);
80 |
81 | if (isFirstItemInRow) {
82 | // make sure the first item on a line is left aligned
83 | [currentItemAttributes leftAlignFrameWithSectionInset:sectionInset];
84 | return currentItemAttributes;
85 | }
86 |
87 | CGRect frame = currentItemAttributes.frame;
88 | frame.origin.x = previousFrameRightPoint + [self evaluatedMinimumInteritemSpacingForItemAtIndex:indexPath.row];
89 | currentItemAttributes.frame = frame;
90 | return currentItemAttributes;
91 | }
92 |
93 | - (CGFloat)evaluatedMinimumInteritemSpacingForItemAtIndex:(NSInteger)index
94 | {
95 | if ([self.collectionView.delegate respondsToSelector:@selector(collectionView:layout:minimumInteritemSpacingForSectionAtIndex:)]) {
96 | id delegate = (id)self.collectionView.delegate;
97 |
98 | return [delegate collectionView:self.collectionView layout:self minimumInteritemSpacingForSectionAtIndex:index];
99 | } else {
100 | return self.minimumInteritemSpacing;
101 | }
102 | }
103 |
104 | - (UIEdgeInsets)evaluatedSectionInsetForItemAtIndex:(NSInteger)index
105 | {
106 | if ([self.collectionView.delegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)]) {
107 | id delegate = (id)self.collectionView.delegate;
108 |
109 | return [delegate collectionView:self.collectionView layout:self insetForSectionAtIndex:index];
110 | } else {
111 | return self.sectionInset;
112 | }
113 | }
114 |
115 | @end
116 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CollectionViewSubscriptionLabel
4 | //
5 | // Created by chenyk on 15/4/24.
6 | // Copyright (c) 2015年 chenyk. All rights reserved.
7 | //
8 |
9 | #define kControllerHeaderViewHeight 90
10 | #define kControllerHeaderToCollectionViewMargin 0
11 | #define kCollectionViewCellsHorizonMargin 12
12 | #define kCollectionViewCellHeight 30
13 | #define kCollectionViewItemButtonImageToTextMargin 5
14 |
15 | #define kCollectionViewToLeftMargin 16
16 | #define kCollectionViewToTopMargin 12
17 | #define kCollectionViewToRightMargin 16
18 | #define kCollectionViewToBottomtMargin 10
19 |
20 | #define kCellImageToLabelMargin 10
21 | #define kCellBtnCenterToBorderMargin 19
22 |
23 |
24 | #import "ViewController.h"
25 | #import "UICollectionViewLeftAlignedLayout.h"
26 | #import "CollectionViewCell.h"
27 | #import "CollectionHeaderView.h"
28 |
29 |
30 | typedef void(^ISLimitWidth)(BOOL yesORNo,id data);
31 |
32 |
33 | static NSString * const kCellIdentifier = @"CellIdentifier";
34 | static NSString * const kHeaderViewCellIdentifier = @"HeaderViewCellIdentifier";
35 |
36 | @interface ViewController ()
37 |
38 | @property (nonatomic, strong) UICollectionView *collectionView;
39 | @property (nonatomic, strong) NSMutableArray *dataSource;
40 |
41 |
42 | @end
43 |
44 | @implementation ViewController
45 |
46 | - (void)viewDidLoad {
47 | [super viewDidLoad];
48 | // Do any additional setup after loading the view, typically from a nib.
49 |
50 |
51 |
52 | self.dataSource = [NSMutableArray array];
53 | NSMutableArray * array1 = [@[@"推荐",@"热点",@"汽车",@"财经频道",@"热点",@"社会",@"明星八卦",@"IT科技",@"移动互联网",@"金融",@"大数据",@"股票期货",@"食品安全新闻",@"自定义标签"]mutableCopy];
54 |
55 | [self.dataSource addObject:array1];
56 | NSMutableArray * array2 = [@[@"推荐",@"热点",@"汽车",@"财经频道",@"热点",@"社会",@"明星八卦",@"IT科技",@"移动互联网",@"金融",@"大数据",@"股票期货",@"食品安全新闻食品食品安全"]mutableCopy];
57 |
58 | [self.dataSource addObject:array2];
59 |
60 | [self addCollectionView];
61 |
62 | }
63 |
64 | - (void)addCollectionView {
65 | CGRect collectionViewFrame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-40);
66 | UICollectionViewLeftAlignedLayout * layout = [[UICollectionViewLeftAlignedLayout alloc] init];
67 | self.collectionView = [[UICollectionView alloc] initWithFrame:collectionViewFrame collectionViewLayout:layout];
68 | self.collectionView.dataSource = self;
69 | self.collectionView.delegate = self;
70 | self.collectionView.backgroundColor = [UIColor whiteColor];
71 | [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:kCellIdentifier];
72 | self.collectionView.allowsMultipleSelection = YES;
73 |
74 | [self.collectionView registerClass:[CollectionHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kHeaderViewCellIdentifier];
75 | self.collectionView.showsHorizontalScrollIndicator = NO;
76 | self.collectionView.contentInset = UIEdgeInsetsMake(15, 0, 0, 0);
77 | self.collectionView.scrollsToTop = NO;
78 | //self.collectionView.scrollEnabled = NO;
79 | [self.view addSubview:self.collectionView];
80 |
81 | }
82 |
83 | #pragma mark - UICollectionViewDataSource
84 |
85 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
86 | {
87 | return [self.dataSource count];
88 | }
89 |
90 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
91 | {
92 | NSMutableArray * array = self.dataSource[section];
93 | return array.count;
94 | }
95 |
96 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
97 | {
98 | CollectionViewCell *cell = (CollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:kCellIdentifier forIndexPath:indexPath];
99 | cell.titleLabel.frame = CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height);
100 |
101 | NSMutableArray * array = self.dataSource[indexPath.section];
102 |
103 | NSString *text = array[indexPath.row];
104 | //cell.titleLabel.backgroundColor = [UIColor orangeColor];
105 | cell.titleLabel.text = text;
106 |
107 | return cell;
108 | }
109 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
110 | {
111 | NSLog(@"%ld",indexPath.row);
112 |
113 | NSMutableArray * array1 = indexPath.section == 0?self.dataSource[1]:self.dataSource[0];
114 | NSMutableArray * array2 = indexPath.section == 1?self.dataSource[1]:self.dataSource[0];
115 | [array1 addObject:array2[indexPath.row]];
116 | [array2 removeObjectAtIndex:indexPath.row];
117 |
118 | [self.collectionView reloadData];
119 |
120 |
121 | }
122 |
123 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
124 | viewForSupplementaryElementOfKind:(NSString *)kind
125 | atIndexPath:(NSIndexPath *)indexPath
126 | {
127 | if ([kind isEqual:UICollectionElementKindSectionHeader]) {
128 | CollectionHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kHeaderViewCellIdentifier forIndexPath:indexPath];
129 | NSString * str = indexPath.section == 0 ? @"我的订阅":@"未订阅";
130 | headerView.titleLabel.text = str;
131 | return (UICollectionReusableView *)headerView;
132 | }
133 | return nil;
134 | }
135 |
136 |
137 | - (float)getCollectionCellWidthText:(NSString *)text{
138 | float cellWidth;
139 | CGSize size = [text sizeWithAttributes:
140 | @{NSFontAttributeName:
141 | [UIFont systemFontOfSize:13]}];
142 |
143 | cellWidth = ceilf(size.width) + kCellBtnCenterToBorderMargin;
144 | cellWidth = [self checkCellLimitWidth:cellWidth isLimitWidth:nil];
145 | return cellWidth;
146 | }
147 |
148 |
149 | - (float)checkCellLimitWidth:(float)cellWidth isLimitWidth:(ISLimitWidth)isLimitWidth {
150 | float limitWidth = (CGRectGetWidth(self.collectionView.frame)-kCollectionViewToLeftMargin-kCollectionViewToRightMargin);
151 | if (cellWidth >= limitWidth) {
152 | cellWidth = limitWidth;
153 | isLimitWidth?isLimitWidth(YES,@(cellWidth)):nil;
154 | return cellWidth;
155 | }
156 | isLimitWidth?isLimitWidth(NO,@(cellWidth)):nil;
157 | return cellWidth;
158 | }
159 |
160 | #pragma mark - UICollectionViewDelegateLeftAlignedLayout
161 |
162 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
163 | {
164 | // cell 的宽
165 | NSMutableArray * array = self.dataSource[indexPath.section];
166 | NSString *text = array[indexPath.row];
167 | float cellWidth = [self getCollectionCellWidthText:text];
168 | return CGSizeMake(cellWidth, kCollectionViewCellHeight);
169 | }
170 |
171 |
172 |
173 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
174 | {
175 | return kCollectionViewCellsHorizonMargin;//cell之间的间隔
176 | }
177 |
178 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
179 | {
180 | return CGSizeMake([UIScreen mainScreen].bounds.size.width - 50, 38);
181 | }
182 |
183 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
184 | {
185 | //四周边距
186 | return UIEdgeInsetsMake(kCollectionViewToTopMargin, kCollectionViewToLeftMargin, kCollectionViewToBottomtMargin, kCollectionViewToRightMargin);
187 | }
188 |
189 |
190 | - (void)didReceiveMemoryWarning {
191 | [super didReceiveMemoryWarning];
192 | // Dispose of any resources that can be recreated.
193 | }
194 |
195 | @end
196 |
--------------------------------------------------------------------------------
/CollectionViewSubscriptionLabel.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | E150BABE1AEA0DB0007D25B4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E150BABD1AEA0DB0007D25B4 /* main.m */; };
11 | E150BAC11AEA0DB0007D25B4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E150BAC01AEA0DB0007D25B4 /* AppDelegate.m */; };
12 | E150BAC41AEA0DB0007D25B4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E150BAC31AEA0DB0007D25B4 /* ViewController.m */; };
13 | E150BAC71AEA0DB0007D25B4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E150BAC51AEA0DB0007D25B4 /* Main.storyboard */; };
14 | E150BAC91AEA0DB0007D25B4 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E150BAC81AEA0DB0007D25B4 /* Images.xcassets */; };
15 | E150BACC1AEA0DB0007D25B4 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = E150BACA1AEA0DB0007D25B4 /* LaunchScreen.xib */; };
16 | E150BAD81AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E150BAD71AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.m */; };
17 | E150BAE41AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = E150BAE31AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout.m */; };
18 | E150BAE71AEA0E1A007D25B4 /* CollectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E150BAE61AEA0E1A007D25B4 /* CollectionHeaderView.m */; };
19 | E150BAEA1AEA0E41007D25B4 /* CollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E150BAE91AEA0E41007D25B4 /* CollectionViewCell.m */; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXContainerItemProxy section */
23 | E150BAD21AEA0DB0007D25B4 /* PBXContainerItemProxy */ = {
24 | isa = PBXContainerItemProxy;
25 | containerPortal = E150BAB01AEA0DB0007D25B4 /* Project object */;
26 | proxyType = 1;
27 | remoteGlobalIDString = E150BAB71AEA0DB0007D25B4;
28 | remoteInfo = CollectionViewSubscriptionLabel;
29 | };
30 | /* End PBXContainerItemProxy section */
31 |
32 | /* Begin PBXFileReference section */
33 | E150BAB81AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionViewSubscriptionLabel.app; sourceTree = BUILT_PRODUCTS_DIR; };
34 | E150BABC1AEA0DB0007D25B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
35 | E150BABD1AEA0DB0007D25B4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
36 | E150BABF1AEA0DB0007D25B4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
37 | E150BAC01AEA0DB0007D25B4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
38 | E150BAC21AEA0DB0007D25B4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
39 | E150BAC31AEA0DB0007D25B4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
40 | E150BAC61AEA0DB0007D25B4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
41 | E150BAC81AEA0DB0007D25B4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
42 | E150BACB1AEA0DB0007D25B4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
43 | E150BAD11AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CollectionViewSubscriptionLabelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
44 | E150BAD61AEA0DB0007D25B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
45 | E150BAD71AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CollectionViewSubscriptionLabelTests.m; sourceTree = ""; };
46 | E150BAE21AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICollectionViewLeftAlignedLayout.h; sourceTree = ""; };
47 | E150BAE31AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICollectionViewLeftAlignedLayout.m; sourceTree = ""; };
48 | E150BAE51AEA0E1A007D25B4 /* CollectionHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionHeaderView.h; sourceTree = ""; };
49 | E150BAE61AEA0E1A007D25B4 /* CollectionHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollectionHeaderView.m; sourceTree = ""; };
50 | E150BAE81AEA0E41007D25B4 /* CollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionViewCell.h; sourceTree = ""; };
51 | E150BAE91AEA0E41007D25B4 /* CollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollectionViewCell.m; sourceTree = ""; };
52 | /* End PBXFileReference section */
53 |
54 | /* Begin PBXFrameworksBuildPhase section */
55 | E150BAB51AEA0DB0007D25B4 /* Frameworks */ = {
56 | isa = PBXFrameworksBuildPhase;
57 | buildActionMask = 2147483647;
58 | files = (
59 | );
60 | runOnlyForDeploymentPostprocessing = 0;
61 | };
62 | E150BACE1AEA0DB0007D25B4 /* Frameworks */ = {
63 | isa = PBXFrameworksBuildPhase;
64 | buildActionMask = 2147483647;
65 | files = (
66 | );
67 | runOnlyForDeploymentPostprocessing = 0;
68 | };
69 | /* End PBXFrameworksBuildPhase section */
70 |
71 | /* Begin PBXGroup section */
72 | E150BAAF1AEA0DB0007D25B4 = {
73 | isa = PBXGroup;
74 | children = (
75 | E150BABA1AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel */,
76 | E150BAD41AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests */,
77 | E150BAB91AEA0DB0007D25B4 /* Products */,
78 | );
79 | sourceTree = "";
80 | };
81 | E150BAB91AEA0DB0007D25B4 /* Products */ = {
82 | isa = PBXGroup;
83 | children = (
84 | E150BAB81AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel.app */,
85 | E150BAD11AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.xctest */,
86 | );
87 | name = Products;
88 | sourceTree = "";
89 | };
90 | E150BABA1AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel */ = {
91 | isa = PBXGroup;
92 | children = (
93 | E150BAE11AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout */,
94 | E150BABF1AEA0DB0007D25B4 /* AppDelegate.h */,
95 | E150BAC01AEA0DB0007D25B4 /* AppDelegate.m */,
96 | E150BAC21AEA0DB0007D25B4 /* ViewController.h */,
97 | E150BAC31AEA0DB0007D25B4 /* ViewController.m */,
98 | E150BAE51AEA0E1A007D25B4 /* CollectionHeaderView.h */,
99 | E150BAE61AEA0E1A007D25B4 /* CollectionHeaderView.m */,
100 | E150BAE81AEA0E41007D25B4 /* CollectionViewCell.h */,
101 | E150BAE91AEA0E41007D25B4 /* CollectionViewCell.m */,
102 | E150BAC51AEA0DB0007D25B4 /* Main.storyboard */,
103 | E150BAC81AEA0DB0007D25B4 /* Images.xcassets */,
104 | E150BACA1AEA0DB0007D25B4 /* LaunchScreen.xib */,
105 | E150BABB1AEA0DB0007D25B4 /* Supporting Files */,
106 | );
107 | path = CollectionViewSubscriptionLabel;
108 | sourceTree = "";
109 | };
110 | E150BABB1AEA0DB0007D25B4 /* Supporting Files */ = {
111 | isa = PBXGroup;
112 | children = (
113 | E150BABC1AEA0DB0007D25B4 /* Info.plist */,
114 | E150BABD1AEA0DB0007D25B4 /* main.m */,
115 | );
116 | name = "Supporting Files";
117 | sourceTree = "";
118 | };
119 | E150BAD41AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests */ = {
120 | isa = PBXGroup;
121 | children = (
122 | E150BAD71AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.m */,
123 | E150BAD51AEA0DB0007D25B4 /* Supporting Files */,
124 | );
125 | path = CollectionViewSubscriptionLabelTests;
126 | sourceTree = "";
127 | };
128 | E150BAD51AEA0DB0007D25B4 /* Supporting Files */ = {
129 | isa = PBXGroup;
130 | children = (
131 | E150BAD61AEA0DB0007D25B4 /* Info.plist */,
132 | );
133 | name = "Supporting Files";
134 | sourceTree = "";
135 | };
136 | E150BAE11AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout */ = {
137 | isa = PBXGroup;
138 | children = (
139 | E150BAE21AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout.h */,
140 | E150BAE31AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout.m */,
141 | );
142 | path = UICollectionViewLeftAlignedLayout;
143 | sourceTree = "";
144 | };
145 | /* End PBXGroup section */
146 |
147 | /* Begin PBXNativeTarget section */
148 | E150BAB71AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel */ = {
149 | isa = PBXNativeTarget;
150 | buildConfigurationList = E150BADB1AEA0DB0007D25B4 /* Build configuration list for PBXNativeTarget "CollectionViewSubscriptionLabel" */;
151 | buildPhases = (
152 | E150BAB41AEA0DB0007D25B4 /* Sources */,
153 | E150BAB51AEA0DB0007D25B4 /* Frameworks */,
154 | E150BAB61AEA0DB0007D25B4 /* Resources */,
155 | );
156 | buildRules = (
157 | );
158 | dependencies = (
159 | );
160 | name = CollectionViewSubscriptionLabel;
161 | productName = CollectionViewSubscriptionLabel;
162 | productReference = E150BAB81AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel.app */;
163 | productType = "com.apple.product-type.application";
164 | };
165 | E150BAD01AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests */ = {
166 | isa = PBXNativeTarget;
167 | buildConfigurationList = E150BADE1AEA0DB0007D25B4 /* Build configuration list for PBXNativeTarget "CollectionViewSubscriptionLabelTests" */;
168 | buildPhases = (
169 | E150BACD1AEA0DB0007D25B4 /* Sources */,
170 | E150BACE1AEA0DB0007D25B4 /* Frameworks */,
171 | E150BACF1AEA0DB0007D25B4 /* Resources */,
172 | );
173 | buildRules = (
174 | );
175 | dependencies = (
176 | E150BAD31AEA0DB0007D25B4 /* PBXTargetDependency */,
177 | );
178 | name = CollectionViewSubscriptionLabelTests;
179 | productName = CollectionViewSubscriptionLabelTests;
180 | productReference = E150BAD11AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.xctest */;
181 | productType = "com.apple.product-type.bundle.unit-test";
182 | };
183 | /* End PBXNativeTarget section */
184 |
185 | /* Begin PBXProject section */
186 | E150BAB01AEA0DB0007D25B4 /* Project object */ = {
187 | isa = PBXProject;
188 | attributes = {
189 | LastUpgradeCheck = 0630;
190 | ORGANIZATIONNAME = chenyk;
191 | TargetAttributes = {
192 | E150BAB71AEA0DB0007D25B4 = {
193 | CreatedOnToolsVersion = 6.3;
194 | };
195 | E150BAD01AEA0DB0007D25B4 = {
196 | CreatedOnToolsVersion = 6.3;
197 | TestTargetID = E150BAB71AEA0DB0007D25B4;
198 | };
199 | };
200 | };
201 | buildConfigurationList = E150BAB31AEA0DB0007D25B4 /* Build configuration list for PBXProject "CollectionViewSubscriptionLabel" */;
202 | compatibilityVersion = "Xcode 3.2";
203 | developmentRegion = English;
204 | hasScannedForEncodings = 0;
205 | knownRegions = (
206 | en,
207 | Base,
208 | );
209 | mainGroup = E150BAAF1AEA0DB0007D25B4;
210 | productRefGroup = E150BAB91AEA0DB0007D25B4 /* Products */;
211 | projectDirPath = "";
212 | projectRoot = "";
213 | targets = (
214 | E150BAB71AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel */,
215 | E150BAD01AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests */,
216 | );
217 | };
218 | /* End PBXProject section */
219 |
220 | /* Begin PBXResourcesBuildPhase section */
221 | E150BAB61AEA0DB0007D25B4 /* Resources */ = {
222 | isa = PBXResourcesBuildPhase;
223 | buildActionMask = 2147483647;
224 | files = (
225 | E150BAC71AEA0DB0007D25B4 /* Main.storyboard in Resources */,
226 | E150BACC1AEA0DB0007D25B4 /* LaunchScreen.xib in Resources */,
227 | E150BAC91AEA0DB0007D25B4 /* Images.xcassets in Resources */,
228 | );
229 | runOnlyForDeploymentPostprocessing = 0;
230 | };
231 | E150BACF1AEA0DB0007D25B4 /* Resources */ = {
232 | isa = PBXResourcesBuildPhase;
233 | buildActionMask = 2147483647;
234 | files = (
235 | );
236 | runOnlyForDeploymentPostprocessing = 0;
237 | };
238 | /* End PBXResourcesBuildPhase section */
239 |
240 | /* Begin PBXSourcesBuildPhase section */
241 | E150BAB41AEA0DB0007D25B4 /* Sources */ = {
242 | isa = PBXSourcesBuildPhase;
243 | buildActionMask = 2147483647;
244 | files = (
245 | E150BAEA1AEA0E41007D25B4 /* CollectionViewCell.m in Sources */,
246 | E150BAE41AEA0DCB007D25B4 /* UICollectionViewLeftAlignedLayout.m in Sources */,
247 | E150BAC41AEA0DB0007D25B4 /* ViewController.m in Sources */,
248 | E150BAC11AEA0DB0007D25B4 /* AppDelegate.m in Sources */,
249 | E150BABE1AEA0DB0007D25B4 /* main.m in Sources */,
250 | E150BAE71AEA0E1A007D25B4 /* CollectionHeaderView.m in Sources */,
251 | );
252 | runOnlyForDeploymentPostprocessing = 0;
253 | };
254 | E150BACD1AEA0DB0007D25B4 /* Sources */ = {
255 | isa = PBXSourcesBuildPhase;
256 | buildActionMask = 2147483647;
257 | files = (
258 | E150BAD81AEA0DB0007D25B4 /* CollectionViewSubscriptionLabelTests.m in Sources */,
259 | );
260 | runOnlyForDeploymentPostprocessing = 0;
261 | };
262 | /* End PBXSourcesBuildPhase section */
263 |
264 | /* Begin PBXTargetDependency section */
265 | E150BAD31AEA0DB0007D25B4 /* PBXTargetDependency */ = {
266 | isa = PBXTargetDependency;
267 | target = E150BAB71AEA0DB0007D25B4 /* CollectionViewSubscriptionLabel */;
268 | targetProxy = E150BAD21AEA0DB0007D25B4 /* PBXContainerItemProxy */;
269 | };
270 | /* End PBXTargetDependency section */
271 |
272 | /* Begin PBXVariantGroup section */
273 | E150BAC51AEA0DB0007D25B4 /* Main.storyboard */ = {
274 | isa = PBXVariantGroup;
275 | children = (
276 | E150BAC61AEA0DB0007D25B4 /* Base */,
277 | );
278 | name = Main.storyboard;
279 | sourceTree = "";
280 | };
281 | E150BACA1AEA0DB0007D25B4 /* LaunchScreen.xib */ = {
282 | isa = PBXVariantGroup;
283 | children = (
284 | E150BACB1AEA0DB0007D25B4 /* Base */,
285 | );
286 | name = LaunchScreen.xib;
287 | sourceTree = "";
288 | };
289 | /* End PBXVariantGroup section */
290 |
291 | /* Begin XCBuildConfiguration section */
292 | E150BAD91AEA0DB0007D25B4 /* Debug */ = {
293 | isa = XCBuildConfiguration;
294 | buildSettings = {
295 | ALWAYS_SEARCH_USER_PATHS = NO;
296 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
297 | CLANG_CXX_LIBRARY = "libc++";
298 | CLANG_ENABLE_MODULES = YES;
299 | CLANG_ENABLE_OBJC_ARC = YES;
300 | CLANG_WARN_BOOL_CONVERSION = YES;
301 | CLANG_WARN_CONSTANT_CONVERSION = YES;
302 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
303 | CLANG_WARN_EMPTY_BODY = YES;
304 | CLANG_WARN_ENUM_CONVERSION = YES;
305 | CLANG_WARN_INT_CONVERSION = YES;
306 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
307 | CLANG_WARN_UNREACHABLE_CODE = YES;
308 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
309 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
310 | COPY_PHASE_STRIP = NO;
311 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
312 | ENABLE_STRICT_OBJC_MSGSEND = YES;
313 | GCC_C_LANGUAGE_STANDARD = gnu99;
314 | GCC_DYNAMIC_NO_PIC = NO;
315 | GCC_NO_COMMON_BLOCKS = YES;
316 | GCC_OPTIMIZATION_LEVEL = 0;
317 | GCC_PREPROCESSOR_DEFINITIONS = (
318 | "DEBUG=1",
319 | "$(inherited)",
320 | );
321 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
322 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
323 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
324 | GCC_WARN_UNDECLARED_SELECTOR = YES;
325 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
326 | GCC_WARN_UNUSED_FUNCTION = YES;
327 | GCC_WARN_UNUSED_VARIABLE = YES;
328 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
329 | MTL_ENABLE_DEBUG_INFO = YES;
330 | ONLY_ACTIVE_ARCH = YES;
331 | SDKROOT = iphoneos;
332 | };
333 | name = Debug;
334 | };
335 | E150BADA1AEA0DB0007D25B4 /* Release */ = {
336 | isa = XCBuildConfiguration;
337 | buildSettings = {
338 | ALWAYS_SEARCH_USER_PATHS = NO;
339 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
340 | CLANG_CXX_LIBRARY = "libc++";
341 | CLANG_ENABLE_MODULES = YES;
342 | CLANG_ENABLE_OBJC_ARC = YES;
343 | CLANG_WARN_BOOL_CONVERSION = YES;
344 | CLANG_WARN_CONSTANT_CONVERSION = YES;
345 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
346 | CLANG_WARN_EMPTY_BODY = YES;
347 | CLANG_WARN_ENUM_CONVERSION = YES;
348 | CLANG_WARN_INT_CONVERSION = YES;
349 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
350 | CLANG_WARN_UNREACHABLE_CODE = YES;
351 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
352 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
353 | COPY_PHASE_STRIP = NO;
354 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
355 | ENABLE_NS_ASSERTIONS = NO;
356 | ENABLE_STRICT_OBJC_MSGSEND = YES;
357 | GCC_C_LANGUAGE_STANDARD = gnu99;
358 | GCC_NO_COMMON_BLOCKS = YES;
359 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
360 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
361 | GCC_WARN_UNDECLARED_SELECTOR = YES;
362 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
363 | GCC_WARN_UNUSED_FUNCTION = YES;
364 | GCC_WARN_UNUSED_VARIABLE = YES;
365 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
366 | MTL_ENABLE_DEBUG_INFO = NO;
367 | SDKROOT = iphoneos;
368 | VALIDATE_PRODUCT = YES;
369 | };
370 | name = Release;
371 | };
372 | E150BADC1AEA0DB0007D25B4 /* Debug */ = {
373 | isa = XCBuildConfiguration;
374 | buildSettings = {
375 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
376 | INFOPLIST_FILE = CollectionViewSubscriptionLabel/Info.plist;
377 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
378 | PRODUCT_NAME = "$(TARGET_NAME)";
379 | };
380 | name = Debug;
381 | };
382 | E150BADD1AEA0DB0007D25B4 /* Release */ = {
383 | isa = XCBuildConfiguration;
384 | buildSettings = {
385 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
386 | INFOPLIST_FILE = CollectionViewSubscriptionLabel/Info.plist;
387 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
388 | PRODUCT_NAME = "$(TARGET_NAME)";
389 | };
390 | name = Release;
391 | };
392 | E150BADF1AEA0DB0007D25B4 /* Debug */ = {
393 | isa = XCBuildConfiguration;
394 | buildSettings = {
395 | BUNDLE_LOADER = "$(TEST_HOST)";
396 | FRAMEWORK_SEARCH_PATHS = (
397 | "$(SDKROOT)/Developer/Library/Frameworks",
398 | "$(inherited)",
399 | );
400 | GCC_PREPROCESSOR_DEFINITIONS = (
401 | "DEBUG=1",
402 | "$(inherited)",
403 | );
404 | INFOPLIST_FILE = CollectionViewSubscriptionLabelTests/Info.plist;
405 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
406 | PRODUCT_NAME = "$(TARGET_NAME)";
407 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CollectionViewSubscriptionLabel.app/CollectionViewSubscriptionLabel";
408 | };
409 | name = Debug;
410 | };
411 | E150BAE01AEA0DB0007D25B4 /* Release */ = {
412 | isa = XCBuildConfiguration;
413 | buildSettings = {
414 | BUNDLE_LOADER = "$(TEST_HOST)";
415 | FRAMEWORK_SEARCH_PATHS = (
416 | "$(SDKROOT)/Developer/Library/Frameworks",
417 | "$(inherited)",
418 | );
419 | INFOPLIST_FILE = CollectionViewSubscriptionLabelTests/Info.plist;
420 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
421 | PRODUCT_NAME = "$(TARGET_NAME)";
422 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CollectionViewSubscriptionLabel.app/CollectionViewSubscriptionLabel";
423 | };
424 | name = Release;
425 | };
426 | /* End XCBuildConfiguration section */
427 |
428 | /* Begin XCConfigurationList section */
429 | E150BAB31AEA0DB0007D25B4 /* Build configuration list for PBXProject "CollectionViewSubscriptionLabel" */ = {
430 | isa = XCConfigurationList;
431 | buildConfigurations = (
432 | E150BAD91AEA0DB0007D25B4 /* Debug */,
433 | E150BADA1AEA0DB0007D25B4 /* Release */,
434 | );
435 | defaultConfigurationIsVisible = 0;
436 | defaultConfigurationName = Release;
437 | };
438 | E150BADB1AEA0DB0007D25B4 /* Build configuration list for PBXNativeTarget "CollectionViewSubscriptionLabel" */ = {
439 | isa = XCConfigurationList;
440 | buildConfigurations = (
441 | E150BADC1AEA0DB0007D25B4 /* Debug */,
442 | E150BADD1AEA0DB0007D25B4 /* Release */,
443 | );
444 | defaultConfigurationIsVisible = 0;
445 | };
446 | E150BADE1AEA0DB0007D25B4 /* Build configuration list for PBXNativeTarget "CollectionViewSubscriptionLabelTests" */ = {
447 | isa = XCConfigurationList;
448 | buildConfigurations = (
449 | E150BADF1AEA0DB0007D25B4 /* Debug */,
450 | E150BAE01AEA0DB0007D25B4 /* Release */,
451 | );
452 | defaultConfigurationIsVisible = 0;
453 | };
454 | /* End XCConfigurationList section */
455 | };
456 | rootObject = E150BAB01AEA0DB0007D25B4 /* Project object */;
457 | }
458 |
--------------------------------------------------------------------------------