diff --git a/YSLContainerViewController/Constants.h b/YSLContainerViewController/Constants.h new file mode 100644 index 0000000..bc3da56 --- /dev/null +++ b/YSLContainerViewController/Constants.h @@ -0,0 +1,21 @@ +// +// Constants.h +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 03/07/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#ifndef Constants_h +#define Constants_h + +#define kYSLScrollMenuViewWidth 110 +#define kYSLScrollMenuViewMargin 10 +#define kYSLIndicatorHeight 1.5f +#define kYSLScrollMenuViewHeight 45.5f + +#define menuHasShadow NO +#define categoryImageHeight 212.0f +#define middleTitleHeight 40.0f + +#endif /* Constants_h */ diff --git a/YSLContainerViewController/YSLContainerViewController.h b/YSLContainerViewController/YSLContainerViewController.h index 0b65c5f..299051a 100644 --- a/YSLContainerViewController/YSLContainerViewController.h +++ b/YSLContainerViewController/YSLContainerViewController.h @@ -29,7 +29,9 @@ @property (nonatomic, strong) UIColor *menuIndicatorColor; - (id)initWithControllers:(NSArray *)controllers - topBarHeight:(CGFloat)topBarHeight - parentViewController:(UIViewController *)parentViewController; + parentViewController:(UIViewController *)parentViewController + heightOfView:(float) heightOfView; + +- (void) goToSelectedViewController:(NSInteger)index; @end diff --git a/YSLContainerViewController/YSLContainerViewController.m b/YSLContainerViewController/YSLContainerViewController.m index d05cc78..e8f8c98 100644 --- a/YSLContainerViewController/YSLContainerViewController.m +++ b/YSLContainerViewController/YSLContainerViewController.m @@ -8,12 +8,11 @@ #import "YSLContainerViewController.h" #import "YSLScrollMenuView.h" - -static const CGFloat kYSLScrollMenuViewHeight = 40; +#import "Constants.h" @interface YSLContainerViewController () -@property (nonatomic, assign) CGFloat topBarHeight; +@property (nonatomic, assign) CGFloat heightOfView; @property (nonatomic, assign) NSInteger currentIndex; @property (nonatomic, strong) YSLScrollMenuView *menuView; @@ -22,23 +21,22 @@ @interface YSLContainerViewController () = 0 && targetIndex < self.childControllers.count) { + if (targetIndex >= 0 && targetIndex < self.childControllers.count) + { // MenuView Move CGFloat indicatorUpdateRatio = ratio; if (isToNextItem) { @@ -162,7 +162,8 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView indicatorUpdateRatio = indicatorUpdateRatio * 1; [_menuView setIndicatorViewFrameWithRatio:indicatorUpdateRatio isNextItem:isToNextItem toIndex:self.currentIndex]; - } else { + } else + { CGPoint offset = _menuView.scrollView.contentOffset; offset.x = currentItemOffsetX - (nextItemOffsetX - currentItemOffsetX) * ratio; diff --git a/YSLContainerViewController/YSLScrollMenuView.h b/YSLContainerViewController/YSLScrollMenuView.h index 5b77d83..dcaca88 100644 --- a/YSLContainerViewController/YSLScrollMenuView.h +++ b/YSLContainerViewController/YSLScrollMenuView.h @@ -16,6 +16,7 @@ @interface YSLScrollMenuView : UIView +@property (nonatomic, strong) UIView *indicatorView; @property (nonatomic, weak) id delegate; @property (nonatomic, strong) UIScrollView *scrollView; @property (nonatomic, strong) NSArray *itemTitleArray; @@ -27,8 +28,8 @@ @property (nonatomic, strong) UIColor *itemSelectedTitleColor; @property (nonatomic, strong) UIColor *itemIndicatorColor; -- (void)setShadowView; - +- (void)setShadowView:(BOOL) hasShadow; +- (void)moveIndicatorViewToCurrentIndex:(NSInteger) index; - (void)setIndicatorViewFrameWithRatio:(CGFloat)ratio isNextItem:(BOOL)isNextItem toIndex:(NSInteger)toIndex; - (void)setItemTextColor:(UIColor *)itemTextColor diff --git a/YSLContainerViewController/YSLScrollMenuView.m b/YSLContainerViewController/YSLScrollMenuView.m index 759381e..7a73042 100644 --- a/YSLContainerViewController/YSLScrollMenuView.m +++ b/YSLContainerViewController/YSLScrollMenuView.m @@ -7,16 +7,10 @@ // #import "YSLScrollMenuView.h" - -static const CGFloat kYSLScrollMenuViewWidth = 90; -static const CGFloat kYSLScrollMenuViewMargin = 10; -static const CGFloat kYSLIndicatorHeight = 3; +#import "Constants.h" @interface YSLScrollMenuView () - -@property (nonatomic, strong) UIView *indicatorView; - @end @implementation YSLScrollMenuView @@ -102,12 +96,20 @@ - (void)setItemTitleArray:(NSArray *)itemTitleArray // indicator _indicatorView = [[UIView alloc]init]; - _indicatorView.frame = CGRectMake(10, _scrollView.frame.size.height - kYSLIndicatorHeight, kYSLScrollMenuViewWidth, kYSLIndicatorHeight); + _indicatorView.frame = CGRectMake(0, _scrollView.frame.size.height - kYSLIndicatorHeight , kYSLScrollMenuViewWidth, kYSLIndicatorHeight); _indicatorView.backgroundColor = self.itemIndicatorColor; + [_scrollView addSubview:_indicatorView]; } } +- (void)moveIndicatorViewToCurrentIndex:(NSInteger) index +{ + CGRect rect = _indicatorView.frame; + rect.origin.x = index; + _indicatorView.frame = rect; +} + #pragma mark -- public - (void)setIndicatorViewFrameWithRatio:(CGFloat)ratio isNextItem:(BOOL)isNextItem toIndex:(NSInteger)toIndex @@ -123,7 +125,6 @@ - (void)setIndicatorViewFrameWithRatio:(CGFloat)ratio isNextItem:(BOOL)isNextIte return; } _indicatorView.frame = CGRectMake(indicatorX, _scrollView.frame.size.height - kYSLIndicatorHeight, kYSLScrollMenuViewWidth, kYSLIndicatorHeight); - // NSLog(@"retio : %f",_indicatorView.frame.origin.x); } - (void)setItemTextColor:(UIColor *)itemTextColor @@ -154,12 +155,16 @@ - (void)setItemTextColor:(UIColor *)itemTextColor #pragma mark -- private // menu shadow -- (void)setShadowView +- (void)setShadowView:(BOOL) hasShadow { - UIView *view = [[UIView alloc]init]; - view.frame = CGRectMake(0, self.frame.size.height - 0.5, CGRectGetWidth(self.frame), 0.5); - view.backgroundColor = [UIColor lightGrayColor]; - [self addSubview:view]; + if (hasShadow) + { + UIView *view = [[UIView alloc]init]; + view.frame = CGRectMake(0, self.frame.size.height - 0.5, CGRectGetWidth(self.frame), 0.5); + view.backgroundColor = [UIColor lightGrayColor]; + [self addSubview:view]; + + } } - (void)layoutSubviews diff --git a/YSLContainerViewControllerDemo.xcodeproj/project.pbxproj b/YSLContainerViewControllerDemo.xcodeproj/project.pbxproj index c0e6677..5ae0323 100644 --- a/YSLContainerViewControllerDemo.xcodeproj/project.pbxproj +++ b/YSLContainerViewControllerDemo.xcodeproj/project.pbxproj @@ -7,6 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + BF76DC1E1D25411100AE949A /* HomePageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF76DC1D1D25411100AE949A /* HomePageViewController.m */; }; + BF76DC211D2541A500AE949A /* HomePageCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BF76DC201D2541A500AE949A /* HomePageCollectionViewCell.m */; }; + BF76DC241D26A1EB00AE949A /* CollectionListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF76DC231D26A1EB00AE949A /* CollectionListViewController.m */; }; + BF76DC271D26A25600AE949A /* CollectionCellsCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BF76DC261D26A25600AE949A /* CollectionCellsCollectionViewCell.m */; }; + BF7D5D8C1D292B29006A3900 /* photo_sample_00.png in Resources */ = {isa = PBXBuildFile; fileRef = BF7D5D8A1D292B29006A3900 /* photo_sample_00.png */; }; + BF7D5D8D1D292B29006A3900 /* photo_sample_09.png in Resources */ = {isa = PBXBuildFile; fileRef = BF7D5D8B1D292B29006A3900 /* photo_sample_09.png */; }; D098129D1AC165570085833D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D098129C1AC165570085833D /* main.m */; }; D09812A01AC165570085833D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D098129F1AC165570085833D /* AppDelegate.m */; }; D09812A31AC165570085833D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812A21AC165570085833D /* ViewController.m */; }; @@ -14,8 +20,6 @@ D09812A81AC165570085833D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D09812A71AC165570085833D /* Images.xcassets */; }; D09812AB1AC165570085833D /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09812A91AC165570085833D /* LaunchScreen.xib */; }; D09812B71AC165570085833D /* YSLContainerViewControllerDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812B61AC165570085833D /* YSLContainerViewControllerDemoTests.m */; }; - D09812CB1AC26AEB0085833D /* PlayListTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812C91AC26AEB0085833D /* PlayListTableViewController.m */; }; - D09812CC1AC26AEB0085833D /* PlayListTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09812CA1AC26AEB0085833D /* PlayListTableViewController.xib */; }; D09812D11AC27EE20085833D /* PlayListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812CF1AC27EE20085833D /* PlayListCell.m */; }; D09812D21AC27EE20085833D /* PlayListCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09812D01AC27EE20085833D /* PlayListCell.xib */; }; D09812DC1AC283230085833D /* photo_sample_01.png in Resources */ = {isa = PBXBuildFile; fileRef = D09812D41AC283230085833D /* photo_sample_01.png */; }; @@ -26,14 +30,8 @@ D09812E11AC283230085833D /* photo_sample_06.png in Resources */ = {isa = PBXBuildFile; fileRef = D09812D91AC283230085833D /* photo_sample_06.png */; }; D09812E21AC283230085833D /* photo_sample_07.png in Resources */ = {isa = PBXBuildFile; fileRef = D09812DA1AC283230085833D /* photo_sample_07.png */; }; D09812E31AC283230085833D /* photo_sample_08.png in Resources */ = {isa = PBXBuildFile; fileRef = D09812DB1AC283230085833D /* photo_sample_08.png */; }; - D09812E71AC2849B0085833D /* ArtistsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812E51AC2849B0085833D /* ArtistsViewController.m */; }; - D09812E81AC2849B0085833D /* ArtistsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09812E61AC2849B0085833D /* ArtistsViewController.xib */; }; D09812EC1AC285520085833D /* ArtistsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812EA1AC285520085833D /* ArtistsCell.m */; }; D09812ED1AC285520085833D /* ArtistsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09812EB1AC285520085833D /* ArtistsCell.xib */; }; - D09812F11AC288440085833D /* SampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812EF1AC288440085833D /* SampleViewController.m */; }; - D09812F21AC288440085833D /* SampleViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09812F01AC288440085833D /* SampleViewController.xib */; }; - D09812F61AC2956F0085833D /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D09812F41AC2956F0085833D /* DetailViewController.m */; }; - D09812F71AC2956F0085833D /* DetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09812F51AC2956F0085833D /* DetailViewController.xib */; }; D0DD9FC21AFCB67E002CEBB6 /* YSLContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DD9FBF1AFCB67E002CEBB6 /* YSLContainerViewController.m */; }; D0DD9FC31AFCB67E002CEBB6 /* YSLScrollMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0DD9FC11AFCB67E002CEBB6 /* YSLScrollMenuView.m */; }; /* End PBXBuildFile section */ @@ -49,6 +47,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + BF76DC1C1D25411100AE949A /* HomePageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomePageViewController.h; sourceTree = ""; }; + BF76DC1D1D25411100AE949A /* HomePageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomePageViewController.m; sourceTree = ""; }; + BF76DC1F1D2541A500AE949A /* HomePageCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomePageCollectionViewCell.h; sourceTree = ""; }; + BF76DC201D2541A500AE949A /* HomePageCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomePageCollectionViewCell.m; sourceTree = ""; }; + BF76DC221D26A1EB00AE949A /* CollectionListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CollectionListViewController.h; path = YSLContainerViewControllerDemo/CollectionListViewController.h; sourceTree = SOURCE_ROOT; }; + BF76DC231D26A1EB00AE949A /* CollectionListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CollectionListViewController.m; path = YSLContainerViewControllerDemo/CollectionListViewController.m; sourceTree = SOURCE_ROOT; }; + BF76DC251D26A25600AE949A /* CollectionCellsCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CollectionCellsCollectionViewCell.h; path = YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.h; sourceTree = SOURCE_ROOT; }; + BF76DC261D26A25600AE949A /* CollectionCellsCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CollectionCellsCollectionViewCell.m; path = YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.m; sourceTree = SOURCE_ROOT; }; + BF7D5D8A1D292B29006A3900 /* photo_sample_00.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = photo_sample_00.png; sourceTree = ""; }; + BF7D5D8B1D292B29006A3900 /* photo_sample_09.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = photo_sample_09.png; sourceTree = ""; }; + BF7D5D8E1D293526006A3900 /* Constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; D09812971AC165570085833D /* YSLContainerViewControllerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YSLContainerViewControllerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; D098129B1AC165570085833D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D098129C1AC165570085833D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -62,9 +71,6 @@ D09812B01AC165570085833D /* YSLContainerViewControllerDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YSLContainerViewControllerDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; D09812B51AC165570085833D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D09812B61AC165570085833D /* YSLContainerViewControllerDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YSLContainerViewControllerDemoTests.m; sourceTree = ""; }; - D09812C81AC26AEB0085833D /* PlayListTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlayListTableViewController.h; path = YSLContainerViewControllerDemo/PlayListTableViewController.h; sourceTree = SOURCE_ROOT; }; - D09812C91AC26AEB0085833D /* PlayListTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PlayListTableViewController.m; path = YSLContainerViewControllerDemo/PlayListTableViewController.m; sourceTree = SOURCE_ROOT; }; - D09812CA1AC26AEB0085833D /* PlayListTableViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = PlayListTableViewController.xib; path = YSLContainerViewControllerDemo/PlayListTableViewController.xib; sourceTree = SOURCE_ROOT; }; D09812CE1AC27EE20085833D /* PlayListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlayListCell.h; path = YSLContainerViewControllerDemo/PlayListCell.h; sourceTree = SOURCE_ROOT; }; D09812CF1AC27EE20085833D /* PlayListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PlayListCell.m; path = YSLContainerViewControllerDemo/PlayListCell.m; sourceTree = SOURCE_ROOT; }; D09812D01AC27EE20085833D /* PlayListCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = PlayListCell.xib; path = YSLContainerViewControllerDemo/PlayListCell.xib; sourceTree = SOURCE_ROOT; }; @@ -76,18 +82,9 @@ D09812D91AC283230085833D /* photo_sample_06.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = photo_sample_06.png; sourceTree = ""; }; D09812DA1AC283230085833D /* photo_sample_07.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = photo_sample_07.png; sourceTree = ""; }; D09812DB1AC283230085833D /* photo_sample_08.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = photo_sample_08.png; sourceTree = ""; }; - D09812E41AC2849B0085833D /* ArtistsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ArtistsViewController.h; path = YSLContainerViewControllerDemo/ArtistsViewController.h; sourceTree = SOURCE_ROOT; }; - D09812E51AC2849B0085833D /* ArtistsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ArtistsViewController.m; path = YSLContainerViewControllerDemo/ArtistsViewController.m; sourceTree = SOURCE_ROOT; }; - D09812E61AC2849B0085833D /* ArtistsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ArtistsViewController.xib; path = YSLContainerViewControllerDemo/ArtistsViewController.xib; sourceTree = SOURCE_ROOT; }; D09812E91AC285520085833D /* ArtistsCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ArtistsCell.h; path = YSLContainerViewControllerDemo/ArtistsCell.h; sourceTree = SOURCE_ROOT; }; D09812EA1AC285520085833D /* ArtistsCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ArtistsCell.m; path = YSLContainerViewControllerDemo/ArtistsCell.m; sourceTree = SOURCE_ROOT; }; D09812EB1AC285520085833D /* ArtistsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ArtistsCell.xib; path = YSLContainerViewControllerDemo/ArtistsCell.xib; sourceTree = SOURCE_ROOT; }; - D09812EE1AC288440085833D /* SampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SampleViewController.h; path = YSLContainerViewControllerDemo/SampleViewController.h; sourceTree = SOURCE_ROOT; }; - D09812EF1AC288440085833D /* SampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SampleViewController.m; path = YSLContainerViewControllerDemo/SampleViewController.m; sourceTree = SOURCE_ROOT; }; - D09812F01AC288440085833D /* SampleViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = SampleViewController.xib; path = YSLContainerViewControllerDemo/SampleViewController.xib; sourceTree = SOURCE_ROOT; }; - D09812F31AC2956F0085833D /* DetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetailViewController.h; path = YSLContainerViewControllerDemo/DetailViewController.h; sourceTree = SOURCE_ROOT; }; - D09812F41AC2956F0085833D /* DetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DetailViewController.m; path = YSLContainerViewControllerDemo/DetailViewController.m; sourceTree = SOURCE_ROOT; }; - D09812F51AC2956F0085833D /* DetailViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DetailViewController.xib; path = YSLContainerViewControllerDemo/DetailViewController.xib; sourceTree = SOURCE_ROOT; }; D0DD9FBE1AFCB67E002CEBB6 /* YSLContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YSLContainerViewController.h; sourceTree = ""; }; D0DD9FBF1AFCB67E002CEBB6 /* YSLContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YSLContainerViewController.m; sourceTree = ""; }; D0DD9FC01AFCB67E002CEBB6 /* YSLScrollMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YSLScrollMenuView.h; sourceTree = ""; }; @@ -142,6 +139,10 @@ D09812A11AC165570085833D /* ViewController.h */, D09812A21AC165570085833D /* ViewController.m */, D09812A41AC165570085833D /* Main.storyboard */, + BF76DC1C1D25411100AE949A /* HomePageViewController.h */, + BF76DC1D1D25411100AE949A /* HomePageViewController.m */, + BF76DC1F1D2541A500AE949A /* HomePageCollectionViewCell.h */, + BF76DC201D2541A500AE949A /* HomePageCollectionViewCell.m */, D09812A71AC165570085833D /* Images.xcassets */, D09812A91AC165570085833D /* LaunchScreen.xib */, D098129A1AC165570085833D /* Supporting Files */, @@ -178,18 +179,10 @@ D09812C71AC26A990085833D /* ViewControllers */ = { isa = PBXGroup; children = ( - D09812C81AC26AEB0085833D /* PlayListTableViewController.h */, - D09812C91AC26AEB0085833D /* PlayListTableViewController.m */, - D09812CA1AC26AEB0085833D /* PlayListTableViewController.xib */, - D09812E41AC2849B0085833D /* ArtistsViewController.h */, - D09812E51AC2849B0085833D /* ArtistsViewController.m */, - D09812E61AC2849B0085833D /* ArtistsViewController.xib */, - D09812EE1AC288440085833D /* SampleViewController.h */, - D09812EF1AC288440085833D /* SampleViewController.m */, - D09812F01AC288440085833D /* SampleViewController.xib */, - D09812F31AC2956F0085833D /* DetailViewController.h */, - D09812F41AC2956F0085833D /* DetailViewController.m */, - D09812F51AC2956F0085833D /* DetailViewController.xib */, + BF76DC221D26A1EB00AE949A /* CollectionListViewController.h */, + BF76DC231D26A1EB00AE949A /* CollectionListViewController.m */, + BF76DC251D26A25600AE949A /* CollectionCellsCollectionViewCell.h */, + BF76DC261D26A25600AE949A /* CollectionCellsCollectionViewCell.m */, ); name = ViewControllers; path = YSLContainerViewController; @@ -220,6 +213,8 @@ D09812D91AC283230085833D /* photo_sample_06.png */, D09812DA1AC283230085833D /* photo_sample_07.png */, D09812DB1AC283230085833D /* photo_sample_08.png */, + BF7D5D8A1D292B29006A3900 /* photo_sample_00.png */, + BF7D5D8B1D292B29006A3900 /* photo_sample_09.png */, ); path = Resources; sourceTree = ""; @@ -231,6 +226,7 @@ D0DD9FBF1AFCB67E002CEBB6 /* YSLContainerViewController.m */, D0DD9FC01AFCB67E002CEBB6 /* YSLScrollMenuView.h */, D0DD9FC11AFCB67E002CEBB6 /* YSLScrollMenuView.m */, + BF7D5D8E1D293526006A3900 /* Constants.h */, ); path = YSLContainerViewController; sourceTree = SOURCE_ROOT; @@ -317,21 +313,19 @@ files = ( D09812D21AC27EE20085833D /* PlayListCell.xib in Resources */, D09812A61AC165570085833D /* Main.storyboard in Resources */, - D09812F71AC2956F0085833D /* DetailViewController.xib in Resources */, D09812DD1AC283230085833D /* photo_sample_02.png in Resources */, D09812E31AC283230085833D /* photo_sample_08.png in Resources */, + BF7D5D8C1D292B29006A3900 /* photo_sample_00.png in Resources */, D09812E11AC283230085833D /* photo_sample_06.png in Resources */, D09812E01AC283230085833D /* photo_sample_05.png in Resources */, D09812DE1AC283230085833D /* photo_sample_03.png in Resources */, - D09812CC1AC26AEB0085833D /* PlayListTableViewController.xib in Resources */, D09812AB1AC165570085833D /* LaunchScreen.xib in Resources */, D09812A81AC165570085833D /* Images.xcassets in Resources */, - D09812F21AC288440085833D /* SampleViewController.xib in Resources */, D09812DC1AC283230085833D /* photo_sample_01.png in Resources */, - D09812E81AC2849B0085833D /* ArtistsViewController.xib in Resources */, D09812DF1AC283230085833D /* photo_sample_04.png in Resources */, D09812E21AC283230085833D /* photo_sample_07.png in Resources */, D09812ED1AC285520085833D /* ArtistsCell.xib in Resources */, + BF7D5D8D1D292B29006A3900 /* photo_sample_09.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -349,16 +343,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D09812F11AC288440085833D /* SampleViewController.m in Sources */, D09812A31AC165570085833D /* ViewController.m in Sources */, D09812A01AC165570085833D /* AppDelegate.m in Sources */, - D09812E71AC2849B0085833D /* ArtistsViewController.m in Sources */, + BF76DC211D2541A500AE949A /* HomePageCollectionViewCell.m in Sources */, D098129D1AC165570085833D /* main.m in Sources */, D09812EC1AC285520085833D /* ArtistsCell.m in Sources */, - D09812F61AC2956F0085833D /* DetailViewController.m in Sources */, D09812D11AC27EE20085833D /* PlayListCell.m in Sources */, + BF76DC241D26A1EB00AE949A /* CollectionListViewController.m in Sources */, + BF76DC1E1D25411100AE949A /* HomePageViewController.m in Sources */, + BF76DC271D26A25600AE949A /* CollectionCellsCollectionViewCell.m in Sources */, D0DD9FC31AFCB67E002CEBB6 /* YSLScrollMenuView.m in Sources */, - D09812CB1AC26AEB0085833D /* PlayListTableViewController.m in Sources */, D0DD9FC21AFCB67E002CEBB6 /* YSLContainerViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/YSLContainerViewControllerDemo/AppDelegate.m b/YSLContainerViewControllerDemo/AppDelegate.m index e23c2cd..ce412ae 100644 --- a/YSLContainerViewControllerDemo/AppDelegate.m +++ b/YSLContainerViewControllerDemo/AppDelegate.m @@ -1,6 +1,6 @@ // // AppDelegate.m -// YSLContainerViewControllerDemo +// YSLContainerViewControllerDemo Test // // Created by yamaguchi on 2015/03/24. // Copyright (c) 2015年 h.yamaguchi. All rights reserved. @@ -18,6 +18,7 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [UINavigationBar appearance].barTintColor = [UIColor colorWithRed:0.843137 green:0.843137 blue:0.843137 alpha:1.0]; + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; return YES; } diff --git a/YSLContainerViewControllerDemo/ArtistsViewController.h b/YSLContainerViewControllerDemo/ArtistsViewController.h deleted file mode 100644 index 97c7d56..0000000 --- a/YSLContainerViewControllerDemo/ArtistsViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// ArtistsViewController.h -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import - -@interface ArtistsViewController : UITableViewController - -@end diff --git a/YSLContainerViewControllerDemo/ArtistsViewController.m b/YSLContainerViewControllerDemo/ArtistsViewController.m deleted file mode 100644 index af011e8..0000000 --- a/YSLContainerViewControllerDemo/ArtistsViewController.m +++ /dev/null @@ -1,86 +0,0 @@ -// -// ArtistsViewController.m -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import "ArtistsViewController.h" -#import "ArtistsCell.h" -#import "DetailViewController.h" - -@interface ArtistsViewController () - -@property (nonatomic, strong) NSMutableArray *artistsArray; - -@end - -@implementation ArtistsViewController - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - NSLog(@"ArtistsViewController viewWillAppear"); -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - _artistsArray = [@[@"photo_sample_01", - @"photo_sample_02", - @"photo_sample_03", - @"photo_sample_04", - @"photo_sample_05", - @"photo_sample_06", - @"photo_sample_07", - @"photo_sample_08", - @"photo_sample_01", - @"photo_sample_02", - @"photo_sample_03", - @"photo_sample_04", - @"photo_sample_05", - @"photo_sample_06", - @"photo_sample_07", - @"photo_sample_08",] mutableCopy]; - - [self.tableView registerNib:[UINib nibWithNibName:@"ArtistsCell" bundle:nil] forCellReuseIdentifier:@"ArtistsCell"]; -} - -#pragma mark - Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - // Return the number of sections. - return 1; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - // Return the number of rows in the section. - return _artistsArray.count; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *cellIdentifier = @"ArtistsCell"; - ArtistsCell *cell = (ArtistsCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; - - cell.artWorkImageView.image = [UIImage imageNamed:_artistsArray[indexPath.row]]; - cell.artisttNameLabel.text = [NSString stringWithFormat:@"Artists %ld",(long)indexPath.row]; - return cell; -} - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - DetailViewController *detailVC = [[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil]; - [self.navigationController pushViewController:detailVC animated:YES]; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return 60; -} - -@end diff --git a/YSLContainerViewControllerDemo/ArtistsViewController.xib b/YSLContainerViewControllerDemo/ArtistsViewController.xib deleted file mode 100644 index 877e4d1..0000000 --- a/YSLContainerViewControllerDemo/ArtistsViewController.xib +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/YSLContainerViewControllerDemo/Base.lproj/Main.storyboard b/YSLContainerViewControllerDemo/Base.lproj/Main.storyboard index 0d2ede1..8fe2295 100644 --- a/YSLContainerViewControllerDemo/Base.lproj/Main.storyboard +++ b/YSLContainerViewControllerDemo/Base.lproj/Main.storyboard @@ -1,44 +1,259 @@ - + - + - - + + - - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + - + - - + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.h b/YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.h new file mode 100644 index 0000000..dc0f3d7 --- /dev/null +++ b/YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.h @@ -0,0 +1,16 @@ +// +// CollectionCellsCollectionViewCell.h +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 01/07/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import + +@interface CollectionCellsCollectionViewCell : UICollectionViewCell + +@property (weak, nonatomic) IBOutlet UIImageView *imageView; +@property (weak, nonatomic) IBOutlet UILabel *titleLabel; + +@end diff --git a/YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.m b/YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.m new file mode 100644 index 0000000..891e44f --- /dev/null +++ b/YSLContainerViewControllerDemo/CollectionCellsCollectionViewCell.m @@ -0,0 +1,13 @@ +// +// CollectionCellsCollectionViewCell.m +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 01/07/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import "CollectionCellsCollectionViewCell.h" + +@implementation CollectionCellsCollectionViewCell + +@end diff --git a/YSLContainerViewControllerDemo/CollectionListViewController.h b/YSLContainerViewControllerDemo/CollectionListViewController.h new file mode 100644 index 0000000..64f1337 --- /dev/null +++ b/YSLContainerViewControllerDemo/CollectionListViewController.h @@ -0,0 +1,21 @@ +// +// CollectionListViewController.h +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 01/07/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import + +@protocol ScrollWithContentDelegate + +- (void) scrollingWithContentOffset:(CGFloat) contentOffset; + +@end + +@interface CollectionListViewController : UIViewController + +@property id delegate; + +@end diff --git a/YSLContainerViewControllerDemo/CollectionListViewController.m b/YSLContainerViewControllerDemo/CollectionListViewController.m new file mode 100644 index 0000000..d7e7f75 --- /dev/null +++ b/YSLContainerViewControllerDemo/CollectionListViewController.m @@ -0,0 +1,92 @@ +// +// CollectionListViewController.m +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 01/07/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import "CollectionListViewController.h" +#import "CollectionCellsCollectionViewCell.h" + +@interface CollectionListViewController () + +@property (nonatomic, strong) NSMutableArray *playListArray; +@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView; + +@end + +@implementation CollectionListViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + _playListArray = [@[@"photo_sample_01", + @"photo_sample_02", + @"photo_sample_03", + @"photo_sample_04", + @"photo_sample_05", + @"photo_sample_06", + @"photo_sample_07", + @"photo_sample_08", + @"photo_sample_08", + @"photo_sample_08"] mutableCopy]; + + [self.myCollectionView reloadData]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma -mark CollectionViewDataSource +- (NSInteger)collectionView:(UICollectionView *)collectionView + numberOfItemsInSection:(NSInteger)section +{ + return _playListArray.count; +} + +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView +{ + return 1; +} + +- (CollectionCellsCollectionViewCell *)collectionView:(UICollectionView *)collectionView + cellForItemAtIndexPath:(NSIndexPath *)indexPath +{ + CollectionCellsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCellsCollectionViewCell" forIndexPath:indexPath]; + + [cell.titleLabel setText:[NSString stringWithFormat:@"Playlist %ld",(long)indexPath.row]]; + [cell.imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"photo_sample_0%ld",(long)indexPath.row]]]; + return cell; +} + + +#pragma -mark CollectionViewDelegate + +- (void)collectionView:(UICollectionView *)collectionView +didSelectItemAtIndexPath:(NSIndexPath *)indexPath +{ + +} + +#pragma -mark UICollectionViewDelegateFlowLayout +- (CGSize)collectionView:(UICollectionView *)aCollectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)anIndexPath +{ + return CGSizeMake(self.view.frame.size.width, 80); +} + +#pragma mark ScrollViewDelegate +- (void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + if ([self.delegate respondsToSelector:@selector(scrollingWithContentOffset:)]) + { + [self.delegate scrollingWithContentOffset:scrollView.contentOffset.y]; + } +} + + +@end diff --git a/YSLContainerViewControllerDemo/DetailViewController.h b/YSLContainerViewControllerDemo/DetailViewController.h deleted file mode 100644 index ad7be0b..0000000 --- a/YSLContainerViewControllerDemo/DetailViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// DetailViewController.h -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import - -@interface DetailViewController : UIViewController - -@end diff --git a/YSLContainerViewControllerDemo/DetailViewController.m b/YSLContainerViewControllerDemo/DetailViewController.m deleted file mode 100644 index 7e45072..0000000 --- a/YSLContainerViewControllerDemo/DetailViewController.m +++ /dev/null @@ -1,37 +0,0 @@ -// -// DetailViewController.m -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import "DetailViewController.h" - -@interface DetailViewController () - -@end - -@implementation DetailViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view from its nib. -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -/* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ - -@end diff --git a/YSLContainerViewControllerDemo/DetailViewController.xib b/YSLContainerViewControllerDemo/DetailViewController.xib deleted file mode 100644 index 5f09776..0000000 --- a/YSLContainerViewControllerDemo/DetailViewController.xib +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/YSLContainerViewControllerDemo/HomePageCollectionViewCell.h b/YSLContainerViewControllerDemo/HomePageCollectionViewCell.h new file mode 100644 index 0000000..f412899 --- /dev/null +++ b/YSLContainerViewControllerDemo/HomePageCollectionViewCell.h @@ -0,0 +1,14 @@ +// +// HomePageCollectionViewCell.h +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 30/06/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import + +@interface HomePageCollectionViewCell : UICollectionViewCell +@property (weak, nonatomic) IBOutlet UILabel *titleLabel; + +@end diff --git a/YSLContainerViewControllerDemo/HomePageCollectionViewCell.m b/YSLContainerViewControllerDemo/HomePageCollectionViewCell.m new file mode 100644 index 0000000..b789720 --- /dev/null +++ b/YSLContainerViewControllerDemo/HomePageCollectionViewCell.m @@ -0,0 +1,13 @@ +// +// HomePageCollectionViewCell.m +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 30/06/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import "HomePageCollectionViewCell.h" + +@implementation HomePageCollectionViewCell + +@end diff --git a/YSLContainerViewControllerDemo/HomePageViewController.h b/YSLContainerViewControllerDemo/HomePageViewController.h new file mode 100644 index 0000000..6ffe253 --- /dev/null +++ b/YSLContainerViewControllerDemo/HomePageViewController.h @@ -0,0 +1,13 @@ +// +// HomePageViewController.h +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 30/06/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import + +@interface HomePageViewController : UIViewController + +@end diff --git a/YSLContainerViewControllerDemo/HomePageViewController.m b/YSLContainerViewControllerDemo/HomePageViewController.m new file mode 100644 index 0000000..eaa5fe5 --- /dev/null +++ b/YSLContainerViewControllerDemo/HomePageViewController.m @@ -0,0 +1,78 @@ +// +// HomePageViewController.m +// YSLContainerViewControllerDemo +// +// Created by Gabriel Lupu on 30/06/16. +// Copyright © 2016 h.yamaguchi. All rights reserved. +// + +#import "HomePageViewController.h" +#import "ViewController.h" +#import "HomePageCollectionViewCell.h" + +@interface HomePageViewController () + +@property (nonatomic,strong) NSArray *titlesArray; + +@end + +@implementation HomePageViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.titlesArray = @[@"PlayList",@"Artists",@"Album", @"Track",@"Settings",]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma -mark CollectionViewDelegate Methods +- (NSInteger)collectionView:(UICollectionView *)collectionView + numberOfItemsInSection:(NSInteger)section +{ + return 5; +} + +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView +{ + return 1; +} + +#pragma -mark Create The Cells and Customizations when press +- (HomePageCollectionViewCell *)collectionView:(UICollectionView *)collectionView + cellForItemAtIndexPath:(NSIndexPath *)indexPath +{ + HomePageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomePageCollectionViewCell" forIndexPath:indexPath]; + + [cell.titleLabel setText:self.titlesArray[indexPath.row]]; + return cell; +} + +- (void)collectionView:(UICollectionView *)collectionView +didSelectItemAtIndexPath:(NSIndexPath *)indexPath +{ + + ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; + vc.indexMenu = (int)indexPath.row; + vc.titlesArray = self.titlesArray; + [self.navigationController pushViewController:vc animated:YES]; +} + +- (CGSize)collectionView:(UICollectionView *)aCollectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)anIndexPath +{ + return CGSizeMake(self.view.frame.size.width, 100); +} +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/YSLContainerViewControllerDemo/Images.xcassets/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat0.imageset/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/cat0.imageset/Contents.json new file mode 100644 index 0000000..de25011 --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/cat0.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "barbie-1426039_1280.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat0.imageset/barbie-1426039_1280.jpg b/YSLContainerViewControllerDemo/Images.xcassets/cat0.imageset/barbie-1426039_1280.jpg new file mode 100644 index 0000000..edabf64 Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/cat0.imageset/barbie-1426039_1280.jpg differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat1.imageset/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/cat1.imageset/Contents.json new file mode 100644 index 0000000..6f95883 --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/cat1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "cat1.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat1.imageset/cat1.jpg b/YSLContainerViewControllerDemo/Images.xcassets/cat1.imageset/cat1.jpg new file mode 100644 index 0000000..769dde4 Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/cat1.imageset/cat1.jpg differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat2.imageset/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/cat2.imageset/Contents.json new file mode 100644 index 0000000..09e627d --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/cat2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "sport-shoe-1470061_1280.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat2.imageset/sport-shoe-1470061_1280.jpg b/YSLContainerViewControllerDemo/Images.xcassets/cat2.imageset/sport-shoe-1470061_1280.jpg new file mode 100644 index 0000000..bf446c6 Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/cat2.imageset/sport-shoe-1470061_1280.jpg differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat3.imageset/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/cat3.imageset/Contents.json new file mode 100644 index 0000000..f17a955 --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/cat3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "cat3.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat3.imageset/cat3.jpg b/YSLContainerViewControllerDemo/Images.xcassets/cat3.imageset/cat3.jpg new file mode 100644 index 0000000..a085bb0 Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/cat3.imageset/cat3.jpg differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat4.imageset/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/cat4.imageset/Contents.json new file mode 100644 index 0000000..f09b2ed --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/cat4.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "cat0.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat4.imageset/cat0.jpg b/YSLContainerViewControllerDemo/Images.xcassets/cat4.imageset/cat0.jpg new file mode 100644 index 0000000..c3ab282 Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/cat4.imageset/cat0.jpg differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat5.imageset/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/cat5.imageset/Contents.json new file mode 100644 index 0000000..7cad443 --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/cat5.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "grapes-1476089_1280.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/cat5.imageset/grapes-1476089_1280.jpg b/YSLContainerViewControllerDemo/Images.xcassets/cat5.imageset/grapes-1476089_1280.jpg new file mode 100644 index 0000000..0eedec7 Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/cat5.imageset/grapes-1476089_1280.jpg differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/Contents.json b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/Contents.json new file mode 100644 index 0000000..7e06240 --- /dev/null +++ b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "chevron.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "chevron@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "chevron@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron.png b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron.png new file mode 100644 index 0000000..4b3ccdb Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron.png differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron@2x.png b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron@2x.png new file mode 100644 index 0000000..7ba0cfe Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron@2x.png differ diff --git a/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron@3x.png b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron@3x.png new file mode 100644 index 0000000..c2625fe Binary files /dev/null and b/YSLContainerViewControllerDemo/Images.xcassets/chevron.imageset/chevron@3x.png differ diff --git a/YSLContainerViewControllerDemo/Info.plist b/YSLContainerViewControllerDemo/Info.plist index 03f693d..934a10e 100644 --- a/YSLContainerViewControllerDemo/Info.plist +++ b/YSLContainerViewControllerDemo/Info.plist @@ -30,6 +30,8 @@ armv7 + UIViewControllerBasedStatusBarAppearance + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/YSLContainerViewControllerDemo/PlayListTableViewController.h b/YSLContainerViewControllerDemo/PlayListTableViewController.h deleted file mode 100644 index 85d8972..0000000 --- a/YSLContainerViewControllerDemo/PlayListTableViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// PlayListTableViewController.h -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import - -@interface PlayListTableViewController : UITableViewController - -@end diff --git a/YSLContainerViewControllerDemo/PlayListTableViewController.m b/YSLContainerViewControllerDemo/PlayListTableViewController.m deleted file mode 100644 index 40cd00d..0000000 --- a/YSLContainerViewControllerDemo/PlayListTableViewController.m +++ /dev/null @@ -1,78 +0,0 @@ -// -// PlayListTableViewController.m -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import "PlayListTableViewController.h" -#import "PlayListCell.h" -#import "DetailViewController.h" - -@interface PlayListTableViewController () - -@property (nonatomic, strong) NSMutableArray *playListArray; - -@end - -@implementation PlayListTableViewController - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - NSLog(@"PlayListTableViewController viewWillAppear"); -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - _playListArray = [@[@"photo_sample_01", - @"photo_sample_02", - @"photo_sample_03", - @"photo_sample_04", - @"photo_sample_05", - @"photo_sample_06", - @"photo_sample_07", - @"photo_sample_08",] mutableCopy]; - - [self.tableView registerNib:[UINib nibWithNibName:@"PlayListCell" bundle:nil] forCellReuseIdentifier:@"PlayListCell"]; -} - -#pragma mark - Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - // Return the number of sections. - return 1; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - // Return the number of rows in the section. - return _playListArray.count; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *cellIdentifier = @"PlayListCell"; - PlayListCell *cell = (PlayListCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; - - cell.artWorkImageView.image = [UIImage imageNamed:_playListArray[indexPath.row]]; - cell.playListNameLabel.text = [NSString stringWithFormat:@"PlayList %ld",(long)indexPath.row]; - return cell; -} - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - DetailViewController *detailVC = [[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil]; - [self.navigationController pushViewController:detailVC animated:YES]; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return 80; -} - -@end diff --git a/YSLContainerViewControllerDemo/PlayListTableViewController.xib b/YSLContainerViewControllerDemo/PlayListTableViewController.xib deleted file mode 100644 index b1490a2..0000000 --- a/YSLContainerViewControllerDemo/PlayListTableViewController.xib +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/YSLContainerViewControllerDemo/Resources/photo_sample_00.png b/YSLContainerViewControllerDemo/Resources/photo_sample_00.png new file mode 100644 index 0000000..1ae7eed Binary files /dev/null and b/YSLContainerViewControllerDemo/Resources/photo_sample_00.png differ diff --git a/YSLContainerViewControllerDemo/Resources/photo_sample_09.png b/YSLContainerViewControllerDemo/Resources/photo_sample_09.png new file mode 100644 index 0000000..6e2097b Binary files /dev/null and b/YSLContainerViewControllerDemo/Resources/photo_sample_09.png differ diff --git a/YSLContainerViewControllerDemo/SampleViewController.h b/YSLContainerViewControllerDemo/SampleViewController.h deleted file mode 100644 index 151664b..0000000 --- a/YSLContainerViewControllerDemo/SampleViewController.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// SampleViewController.h -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import - -@interface SampleViewController : UIViewController - -@end diff --git a/YSLContainerViewControllerDemo/SampleViewController.m b/YSLContainerViewControllerDemo/SampleViewController.m deleted file mode 100644 index 633f0a5..0000000 --- a/YSLContainerViewControllerDemo/SampleViewController.m +++ /dev/null @@ -1,30 +0,0 @@ -// -// SampleViewController.m -// YSLContainerViewControllerDemo -// -// Created by yamaguchi on 2015/03/25. -// Copyright (c) 2015年 h.yamaguchi. All rights reserved. -// - -#import "SampleViewController.h" - -@interface SampleViewController () - -@end - -@implementation SampleViewController - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - NSLog(@"SampleViewController viewWillAppear"); -} - -- (void)viewDidLoad { - [super viewDidLoad]; -} - -@end diff --git a/YSLContainerViewControllerDemo/SampleViewController.xib b/YSLContainerViewControllerDemo/SampleViewController.xib deleted file mode 100644 index ebfafb9..0000000 --- a/YSLContainerViewControllerDemo/SampleViewController.xib +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/YSLContainerViewControllerDemo/ViewController.h b/YSLContainerViewControllerDemo/ViewController.h index beba808..1b6fe66 100644 --- a/YSLContainerViewControllerDemo/ViewController.h +++ b/YSLContainerViewControllerDemo/ViewController.h @@ -10,6 +10,8 @@ @interface ViewController : UIViewController +@property (nonatomic, assign) int indexMenu; +@property (nonatomic,strong) NSArray *titlesArray; @end diff --git a/YSLContainerViewControllerDemo/ViewController.m b/YSLContainerViewControllerDemo/ViewController.m index 47774e9..5e9f841 100644 --- a/YSLContainerViewControllerDemo/ViewController.m +++ b/YSLContainerViewControllerDemo/ViewController.m @@ -5,69 +5,234 @@ // Created by yamaguchi on 2015/03/24. // Copyright (c) 2015年 h.yamaguchi. All rights reserved. // +// image download from: http://all-free-download.com/free-photos/download/artist_mother_nature_555965_download.html #import "ViewController.h" #import "YSLContainerViewController.h" -#import "PlayListTableViewController.h" -#import "ArtistsViewController.h" -#import "SampleViewController.h" +#import "CollectionListViewController.h" +#import "Constants.h" -@interface ViewController () +//minimum height should be 64.0 because is the usual height of Navigation Bar. +static const float minimumHeight = 64.0f; + +@interface ViewController () +{ + int currentIndex; +} + +@property (weak, nonatomic) IBOutlet UIImageView *topView; +@property (weak, nonatomic) IBOutlet UIView *bottomView; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightOfTopView; +@property (nonnull,strong) UIVisualEffectView *blurEffectView; +@property (nonatomic,strong) UILabel *middleTitle; +@property (nonatomic,strong) UILabel *titleText; +@property (nonatomic,strong) UIButton *backButton; +@property (nonatomic,strong) YSLContainerViewController *containerVC; @end @implementation ViewController -- (void)didReceiveMemoryWarning { +- (void)didReceiveMemoryWarning +{ [super didReceiveMemoryWarning]; } -- (void)viewDidLoad { +- (void)viewDidLoad +{ [super viewDidLoad]; + [self addBackButtonToScreen]; - // NavigationBar - UILabel *titleView = [[UILabel alloc] initWithFrame:CGRectZero]; - titleView.font = [UIFont fontWithName:@"Futura-Medium" size:19]; - titleView.textColor = [UIColor colorWithRed:0.333333 green:0.333333 blue:0.333333 alpha:1.0]; - titleView.text = @"Menu"; - [titleView sizeToFit]; - titleView.backgroundColor = [UIColor clearColor]; - self.navigationItem.titleView = titleView; + self.heightOfTopView.constant = categoryImageHeight; + [self.topView layoutIfNeeded]; - // SetUp ViewControllers - PlayListTableViewController *playListVC = [[PlayListTableViewController alloc]initWithNibName:@"PlayListTableViewController" bundle:nil]; - playListVC.title = @"PlayList"; + NSMutableArray *viewControllersArray = [[NSMutableArray alloc] init]; + for (int i=0; i< [self.titlesArray count]; i++) + { + CollectionListViewController *playListVC = [self.storyboard instantiateViewControllerWithIdentifier:@"CollectionListViewController"]; + playListVC.title = self.titlesArray[i]; + playListVC.delegate = self; + [viewControllersArray addObject:playListVC]; + } - ArtistsViewController *artistVC = [[ArtistsViewController alloc]initWithNibName:@"ArtistsViewController" bundle:nil]; - artistVC.title = @"Artists"; + self.containerVC = [[YSLContainerViewController alloc] initWithControllers:viewControllersArray + parentViewController:self + heightOfView:self.view.frame.size.height - self.heightOfTopView.constant]; + self.containerVC.delegate = self; + self.containerVC.menuItemFont = [UIFont fontWithName:@"HelveticaNeue" size:12.0f]; + self.containerVC.menuItemSelectedTitleColor = [UIColor colorWithRed:171.0f/255.0f green:4.0f/255.0f blue:16.0f/255.0f alpha:1.0]; + self.containerVC.menuItemTitleColor = [UIColor colorWithRed:162.0f/255.0f green:162.0/255.0f blue:169.0f/255.0f alpha:1]; + self.containerVC.menuIndicatorColor = [UIColor colorWithRed:171.0f/255.0f green:4.0f/255.0f blue:16.0f/255.0f alpha:1.0]; - SampleViewController *sampleVC1 = [[SampleViewController alloc]initWithNibName:@"SampleViewController" bundle:nil]; - sampleVC1.title = @"Album"; + self.containerVC.view.translatesAutoresizingMaskIntoConstraints = NO; + self.containerVC.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.bottomView.frame.size.height); + [self.bottomView addSubview:self.containerVC.view]; - SampleViewController *sampleVC2 = [[SampleViewController alloc]initWithNibName:@"SampleViewController" bundle:nil]; - sampleVC2.title = @"Track"; + NSLayoutConstraint *myConstraint1 = [NSLayoutConstraint constraintWithItem:self.containerVC.view + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.bottomView + attribute:NSLayoutAttributeBottom + multiplier:1.0 + constant:0]; + NSLayoutConstraint *myConstraint2 = [NSLayoutConstraint constraintWithItem:self.containerVC.view + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.bottomView + attribute:NSLayoutAttributeTop + multiplier:1.0 + constant:0]; + NSLayoutConstraint *myConstraint3 = [NSLayoutConstraint constraintWithItem:self.containerVC.view + attribute:NSLayoutAttributeLeft + relatedBy:NSLayoutRelationEqual + toItem:self.bottomView + attribute:NSLayoutAttributeLeft + multiplier:1.0 + constant:0]; + NSLayoutConstraint *myConstraint4 = [NSLayoutConstraint constraintWithItem:self.containerVC.view + attribute:NSLayoutAttributeRight + relatedBy:NSLayoutRelationEqual + toItem:self.bottomView + attribute:NSLayoutAttributeRight + multiplier:1.0 + constant:0]; + [self.bottomView addConstraint:myConstraint1]; + [self.bottomView addConstraint:myConstraint2]; + [self.bottomView addConstraint:myConstraint3]; + [self.bottomView addConstraint:myConstraint4]; + + + self.middleTitle = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2 - 130,categoryImageHeight/2 - middleTitleHeight/2, 260, middleTitleHeight)]; + self.middleTitle.textColor = [UIColor whiteColor]; + self.middleTitle.font = [UIFont fontWithName:@"HelveticaNeue" size:31]; + self.middleTitle.textAlignment = NSTextAlignmentCenter; - SampleViewController *sampleVC3 = [[SampleViewController alloc]initWithNibName:@"SampleViewController" bundle:nil]; - sampleVC3.title = @"Setting"; + currentIndex = self.indexMenu; - // ContainerView - float statusHeight = [[UIApplication sharedApplication] statusBarFrame].size.height; - float navigationHeight = self.navigationController.navigationBar.frame.size.height; + self.topView.image = [UIImage imageNamed:[NSString stringWithFormat:@"cat%d.jpg",currentIndex]]; + self.middleTitle.text = self.titlesArray[currentIndex]; + self.titleText.text = self.titlesArray[currentIndex]; - YSLContainerViewController *containerVC = [[YSLContainerViewController alloc]initWithControllers:@[playListVC,artistVC,sampleVC1,sampleVC2,sampleVC3] - topBarHeight:statusHeight + navigationHeight - parentViewController:self]; - containerVC.delegate = self; - containerVC.menuItemFont = [UIFont fontWithName:@"Futura-Medium" size:16]; + [self.topView addSubview:self.middleTitle]; + [self.view insertSubview:self.titleText aboveSubview:self.blurEffectView]; - [self.view addSubview:containerVC.view]; + [self.containerVC goToSelectedViewController:currentIndex]; } -#pragma mark -- YSLContainerViewControllerDelegate +#pragma mark YSLContainerViewControllerDelegate - (void)containerViewItemIndex:(NSInteger)index currentController:(UIViewController *)controller { -// NSLog(@"current Index : %ld",(long)index); -// NSLog(@"current controller : %@",controller); - [controller viewWillAppear:YES]; + currentIndex = (int)index; + if (currentIndex < [self.titlesArray count]) + { + + self.middleTitle.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.37]; + self.middleTitle.shadowOffset = CGSizeMake(1, 1); + self.middleTitle.layer.masksToBounds = NO; + + self.middleTitle.text = self.titlesArray[currentIndex]; + self.titleText.text = self.titlesArray[currentIndex]; + + [UIView transitionWithView:self.topView + duration:1.0f + options:UIViewAnimationOptionTransitionCrossDissolve + animations:^{ + self.topView.image = [UIImage imageNamed:[NSString stringWithFormat:@"cat%d.jpg",currentIndex]]; + } completion:nil]; + + + } +} + +#pragma mark ScrollWithContentDelegate +- (void) scrollingWithContentOffset:(CGFloat) contentOffset +{ + if (contentOffset < 0) + { + self.middleTitle.alpha = 1 + contentOffset/100; + [UIView animateWithDuration:0.0 animations:^{ + self.middleTitle.frame = CGRectMake(self.view.frame.size.width/2 - 130,categoryImageHeight/2 - middleTitleHeight/2, 260, middleTitleHeight); + }]; + } + else if (contentOffset > 0) + { + self.middleTitle.alpha = 1 - contentOffset/100; + + [UIView animateWithDuration:0.0 animations:^{ + self.middleTitle.frame = CGRectMake(self.view.frame.size.width/2 - 130,categoryImageHeight/2 - middleTitleHeight/2 - contentOffset/2.0f, 260, middleTitleHeight); + }]; + } + + if (categoryImageHeight - contentOffset >= minimumHeight) + { + self.heightOfTopView.constant = categoryImageHeight - contentOffset; + + if (self.blurEffectView || self.titleText) + { + [self.blurEffectView removeFromSuperview]; + [self.titleText removeFromSuperview]; + } + } + else + { + self.heightOfTopView.constant = minimumHeight; + [self addBlurView]; + } + [self.topView layoutIfNeeded]; + + if (contentOffset>=0) + { + CGRect rect = self.containerVC.contentScrollView.frame; + rect.size.height = self.view.frame.size.height - self.heightOfTopView.constant - kYSLScrollMenuViewHeight; + self.containerVC.contentScrollView.frame = rect; + } +} +#pragma mark Actions + +- (void) backAction +{ + [self.navigationController popViewControllerAnimated:YES]; +} + +#pragma mark customize Graphics +- (void) addBackButtonToScreen +{ + self.backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 60)]; + UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(15.2, 34, 16.3, 15)]; + [self.backButton addSubview:imageView]; + [imageView setImage:[UIImage imageNamed:@"chevron"]]; + [self.backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:self.backButton]; +} + +- (void) addBlurView +{ + if (!UIAccessibilityIsReduceTransparencyEnabled()) + { + if (!self.blurEffectView) + { + UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; + self.blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; + self.blurEffectView.frame = CGRectMake(0, 0, self.view.frame.size.width, 64); + } + + if (!self.titleText) + { + self.titleText = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2 - 60, 0, 120, 44)]; + self.titleText.textColor = [UIColor whiteColor]; + self.titleText.font = [UIFont fontWithName:@"Helvetica" size:16]; + self.titleText.textAlignment = NSTextAlignmentCenter; + self.titleText.text = self.titlesArray[currentIndex]; + } + + [self.view insertSubview:self.blurEffectView belowSubview:self.backButton]; + [self.view insertSubview:self.titleText aboveSubview:self.blurEffectView]; + + [UIView animateWithDuration:0.01 animations:^{ + self.titleText.frame = CGRectMake(self.view.frame.size.width/2 - 60, 20, 120, 44); + }]; + } } + + @end