Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an useful property #28

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
45 changes: 37 additions & 8 deletions THSegmentedPager/THSegmentedPager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,60 @@

#import <UIKit/UIKit.h>
#import <HMSegmentedControl/HMSegmentedControl.h>
#import "THSegmentedPageViewControllerDelegate.h"

@interface THSegmentedPager : UIViewController<UIPageViewControllerDataSource,UIPageViewControllerDelegate>

@property (strong, nonatomic)UIPageViewController *pageViewController;
@property (weak, nonatomic) IBOutlet HMSegmentedControl *pageControl;
@property (weak, nonatomic) IBOutlet UIView *contentContainer;
- (instancetype)initWithContentEdgeInsets:(UIEdgeInsets)edgeInsets;

@property (strong, nonatomic, readonly) HMSegmentedControl *pageControl;
@property (strong, nonatomic, readonly) UIPageViewController *pageViewController;
@property (strong, nonatomic, readonly) UIView *contentContainer;

@property (assign, nonatomic) BOOL needPagerAnimateWhenSegmentSelectionChanged; // default is YES

@property (strong, nonatomic) NSArray <UIViewController *> *pages;
@property (assign, nonatomic) BOOL scrollEnable;
@property (assign, nonatomic) BOOL shouldBounce;

@property (strong, nonatomic)NSMutableArray *pages;
@property (assign, nonatomic, getter=isShouldBounce)BOOL shouldBounce;
/*! Instead of setting the pages manually you can give to the controller an array of identifiers which will be loaded from the storyboard at runtime
* \param identifiers Array of identifiers to load
* \param pageIdentifiers Array of identifiers to load
*/
- (void)setupPagesFromStoryboardWithIdentifiers:(NSArray *)identifiers;
- (void)setupPagesFromStoryboardWithIdentifier:(NSString *)storybardIdentifier pageIdentifiers:(NSArray <NSString *> *)pageIdentifiers;
- (void)setupPagesFromStoryboard:(UIStoryboard *)storyboard pageIdentifiers:(NSArray <NSString *> *)pageIdentifiers;
- (void)setupPagesFromStoryboardWithPageIdentifiers:(NSArray <NSString *> *)pageIdentifiers;

- (void)setPageControlHidden:(BOOL)hidden animated:(BOOL)animated;

- (void)setSelectedPageIndex:(NSUInteger)index animated:(BOOL)animated;

- (void)setPageControlHeight:(CGFloat)pageControlHeight;
- (void)setPageControlHeight:(CGFloat)pageControlHeight animated:(BOOL)animated;


/*! Get the selected viewcontroller
* \returns The actual selected viewcontroller
*/
- (UIViewController *)selectedController;
@property (strong, nonatomic, readonly) UIViewController *selectedController;

/*! The control will ask from every viewcontroller an updated title string
*/
- (void)updateTitleLabels;



/**
当前类需要实现的方法,用于返回当前选择的页面索引

@param controller self
@param index 页面索引
*/
- (void)pageViewController:(THSegmentedPager *)controller changeToSelectedIndex:(NSUInteger)index;

@end

@interface UIViewController (THSegmentedPager)

@property (weak, nonatomic) THSegmentedPager *segmentedPager;

@end
386 changes: 308 additions & 78 deletions THSegmentedPager/THSegmentedPager.m

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions THSegmentedPagerExample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@



# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
# Pods - for those of you who use CocoaPods
Pods
Podfile.lock
*.xcuserstate



12 changes: 0 additions & 12 deletions THSegmentedPagerExample/Podfile

This file was deleted.

32 changes: 0 additions & 32 deletions THSegmentedPagerExample/Podfile.lock

This file was deleted.

500 changes: 165 additions & 335 deletions THSegmentedPagerExample/THSegmentedPagerExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 5 additions & 3 deletions THSegmentedPagerExample/THSegmentedPagerExample/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// AppDelegate.h
// THSegmentedPagerExample
// ThSegmentedPagerExample
//
// Created by Hannes Tribus on 25/07/14.
// Copyright (c) 2014 3Bus. All rights reserved.
// Created by 胡金友 on 2017/8/24.
// Copyright © 2017年 胡金友. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand All @@ -12,4 +12,6 @@

@property (strong, nonatomic) UIWindow *window;


@end

Loading