various changes
This commit is contained in:
parent
50d36d42a5
commit
1fcf200a6e
|
|
@ -320,6 +320,7 @@
|
|||
TargetAttributes = {
|
||||
28B63A851A459F5900225C66 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
DevelopmentTeam = 6F2G55XL63;
|
||||
};
|
||||
28B63A9E1A459F5900225C66 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
|
|
@ -505,6 +506,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
INFOPLIST_FILE = XLPagerTabStrip/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
|
@ -515,6 +517,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
INFOPLIST_FILE = XLPagerTabStrip/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ptL-BW-nEP">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ptL-BW-nEP">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
@interface XLTwitterPagerTabStripViewController ()
|
||||
|
||||
@property (nonatomic) IBOutlet UIView * navigationView;
|
||||
@property (nonatomic) UIView * navigationView;
|
||||
@property (nonatomic) UIScrollView * navigationScrollView;
|
||||
@property (nonatomic) FXPageControl * navigationPageControl;
|
||||
@property (nonatomic, strong) NSMutableArray * navigationItemsViews;
|
||||
|
|
@ -26,9 +26,8 @@
|
|||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
if (!self.navigationView.superview) {
|
||||
[self.navigationController.navigationBar addSubview:self.navigationView];
|
||||
self.navigationItem.titleView = self.navigationView;
|
||||
}
|
||||
if (!self.navigationScrollView.superview) {
|
||||
[self.navigationView addSubview:self.navigationScrollView];
|
||||
|
|
@ -38,15 +37,18 @@
|
|||
[self.navigationView addSubview:self.navigationPageControl];
|
||||
}
|
||||
|
||||
_navigationScrollView.bounces = YES;
|
||||
_navigationScrollView.scrollsToTop = NO;
|
||||
_navigationScrollView.delegate = self;
|
||||
_navigationScrollView.showsVerticalScrollIndicator = NO;
|
||||
_navigationScrollView.showsHorizontalScrollIndicator = NO;
|
||||
_navigationScrollView.pagingEnabled = YES;
|
||||
_navigationScrollView.userInteractionEnabled = NO;
|
||||
[_navigationScrollView setAlwaysBounceHorizontal:YES];
|
||||
[_navigationScrollView setAlwaysBounceVertical:NO];
|
||||
|
||||
UIBarButtonItem *flipButton = [[UIBarButtonItem alloc]
|
||||
initWithTitle:@"Flip"
|
||||
style:UIBarButtonItemStyleDone
|
||||
target:self
|
||||
action:nil];
|
||||
UIBarButtonItem *searchButton = [[UIBarButtonItem alloc]
|
||||
initWithTitle:@"Flip"
|
||||
style:UIBarButtonItemStyleDone
|
||||
target:self
|
||||
action:nil];
|
||||
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:flipButton, searchButton, nil];
|
||||
|
||||
[self reloadNavigatorContainerView];
|
||||
}
|
||||
|
|
@ -54,6 +56,7 @@
|
|||
-(void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationView setFrame:CGRectMake(0, 0, CGRectGetWidth(self.navigationController.navigationBar.frame) , CGRectGetHeight(self.navigationController.navigationBar.frame))];
|
||||
[self setCurrentNavigationScrollViewOffset];
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +78,8 @@
|
|||
if (_navigationView) return _navigationView;
|
||||
_navigationView = [[UIView alloc] init];
|
||||
_navigationView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
_navigationView.frame = CGRectMake(0, 0, CGRectGetWidth(self.navigationController.navigationBar.frame) - 16, CGRectGetHeight(self.navigationController.navigationBar.frame));
|
||||
[_navigationView setBackgroundColor:[UIColor redColor]];
|
||||
return _navigationView;
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +88,15 @@
|
|||
if (_navigationScrollView) return _navigationScrollView;
|
||||
_navigationScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 44)];
|
||||
_navigationScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
_navigationScrollView.bounces = YES;
|
||||
_navigationScrollView.scrollsToTop = NO;
|
||||
_navigationScrollView.delegate = self;
|
||||
_navigationScrollView.showsVerticalScrollIndicator = NO;
|
||||
_navigationScrollView.showsHorizontalScrollIndicator = NO;
|
||||
_navigationScrollView.pagingEnabled = YES;
|
||||
_navigationScrollView.userInteractionEnabled = NO;
|
||||
[_navigationScrollView setAlwaysBounceHorizontal:YES];
|
||||
[_navigationScrollView setAlwaysBounceVertical:NO];
|
||||
return _navigationScrollView;
|
||||
}
|
||||
|
||||
|
|
@ -108,18 +122,28 @@
|
|||
|
||||
#pragma mark - XLPagerTabStripViewControllerDataSource
|
||||
|
||||
-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController updateIndicatorToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController
|
||||
{
|
||||
// if (self.shouldUpdateButtonBarView){
|
||||
// NSUInteger newIndex = [self.pagerTabStripChildViewControllers indexOfObject:toViewController];
|
||||
// XLPagerTabStripDirection direction = XLPagerTabStripDirectionLeft;
|
||||
// if (newIndex < [self.pagerTabStripChildViewControllers indexOfObject:fromViewController]){
|
||||
// direction = XLPagerTabStripDirectionRight;
|
||||
// }
|
||||
// [self.buttonBarView moveToIndex:newIndex animated:YES swipeDirection:direction];
|
||||
// }
|
||||
}
|
||||
|
||||
-(void)pagerTabStripViewController:(XLPagerTabStripViewController *)pagerTabStripViewController
|
||||
updateIndicatorFromIndex:(NSInteger)fromIndex
|
||||
toIndex:(NSInteger)toIndex
|
||||
withProgressPercentage:(CGFloat)progressPercentage
|
||||
{
|
||||
CGFloat distance = CGRectGetWidth(self.navigationScrollView.frame) / 2;
|
||||
UIAccelerationValue xOffset = fromIndex < toIndex ? distance * fromIndex + distance * progressPercentage : distance * fromIndex - distance * progressPercentage;
|
||||
[self.navigationScrollView setContentOffset:CGPointMake(xOffset, 0)];
|
||||
[self setAlphaToItemAtIndex:fromIndex withOffset:xOffset];
|
||||
[self setAlphaToItemAtIndex:toIndex withOffset:xOffset];
|
||||
|
||||
[_navigationPageControl setCurrentPage:self.currentIndex];
|
||||
CGFloat distance = [self getDistanceValue];
|
||||
UIAccelerationValue xOffset = fromIndex < toIndex ? distance * fromIndex + distance * progressPercentage : distance * fromIndex - distance * progressPercentage;
|
||||
[self.navigationScrollView setContentOffset:CGPointMake(xOffset, 0)];
|
||||
[self setAlphaWithOffset:xOffset];
|
||||
[_navigationPageControl setCurrentPage:self.currentIndex];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -152,14 +176,14 @@
|
|||
[self.navigationPageControl setNumberOfPages:[self.navigationItemsViews count]];
|
||||
[self.navigationPageControl setCurrentPage:self.currentIndex];
|
||||
CGSize viewSize = [self.navigationPageControl sizeForNumberOfPages:[self.navigationItemsViews count]];
|
||||
CGFloat distance = CGRectGetWidth(self.navigationScrollView.frame) / 2;
|
||||
CGFloat distance = [self getDistanceValue];
|
||||
CGFloat originX = (distance - viewSize.width/2);
|
||||
[self.navigationPageControl setFrame:(CGRect){originX, 34, viewSize.width, viewSize.height}];
|
||||
}
|
||||
|
||||
- (void)addNavigationViewItem:(UIView*)view index:(NSInteger)index
|
||||
{
|
||||
CGFloat distance = CGRectGetWidth(self.navigationScrollView.frame) / 2;
|
||||
CGFloat distance = [self getDistanceValue];
|
||||
CGSize viewSize = [view isKindOfClass:[UILabel class]] ? [self getLabelSize:(UILabel*)view] : view.frame.size;
|
||||
CGFloat originX = (distance - viewSize.width/2) + self.navigationItemsViews.count * distance;
|
||||
view.frame = (CGRect){originX, 8, viewSize.width, viewSize.height};
|
||||
|
|
@ -169,28 +193,14 @@
|
|||
[_navigationItemsViews addObject:view];
|
||||
}
|
||||
|
||||
-(void)setAlphaToItemAtIndex:(NSInteger)index withOffset:(UIAccelerationValue)xOffset
|
||||
-(void)setAlphaWithOffset:(UIAccelerationValue)xOffset
|
||||
{
|
||||
if (index<0 || index>=[self.navigationItemsViews count]) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGFloat distance = CGRectGetWidth(self.navigationScrollView.frame) / 2;
|
||||
CGFloat alpha;
|
||||
|
||||
if(xOffset < distance * index) {
|
||||
alpha = (xOffset - distance * (index - 1)) / distance;
|
||||
}else{
|
||||
alpha = 1 - ((xOffset - distance * index) / distance);
|
||||
}
|
||||
|
||||
UILabel *label = (UILabel*)[self.navigationItemsViews objectAtIndex:index];
|
||||
[label setAlpha:alpha];
|
||||
}
|
||||
|
||||
-(CGSize) getLabelSize:(UILabel *)label
|
||||
{
|
||||
return [[label text] sizeWithAttributes:@{NSFontAttributeName:[label font]}];;
|
||||
CGFloat distance = [self getDistanceValue];
|
||||
[self.navigationItemsViews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
int index = (int)idx;
|
||||
CGFloat alpha = xOffset < distance * index ? (xOffset - distance * (index - 1)) / distance : 1 - ((xOffset - distance * index) / distance);
|
||||
[obj setAlpha:alpha];
|
||||
}];
|
||||
}
|
||||
|
||||
-(UILabel *)createNewLabelWithText:(NSString *)text
|
||||
|
|
@ -203,9 +213,22 @@
|
|||
return navTitleLabel;
|
||||
}
|
||||
|
||||
-(CGSize)getLabelSize:(UILabel *)label
|
||||
{
|
||||
return [[label text] sizeWithAttributes:@{NSFontAttributeName:[label font]}];;
|
||||
}
|
||||
|
||||
-(CGFloat)getDistanceValue
|
||||
{
|
||||
// CGPoint middle = [self.navigationController.navigationBar convertPoint:self.navigationController.navigationBar.center toView:self.navigationView];
|
||||
// CGFloat width = middle.x - self.navigationView.frame.origin.x;
|
||||
CGFloat width = CGRectGetWidth(self.navigationView.frame);
|
||||
return width / 2;
|
||||
}
|
||||
|
||||
-(void)setCurrentNavigationScrollViewOffset
|
||||
{
|
||||
CGFloat distance = CGRectGetWidth(self.navigationScrollView.frame) / 2;
|
||||
CGFloat distance = [self getDistanceValue];
|
||||
UIAccelerationValue xOffset = distance * self.currentIndex;
|
||||
[self.navigationScrollView setContentOffset:CGPointMake(xOffset, 0)];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue