- Fix
This commit is contained in:
parent
5ecc0d4203
commit
3dc7c75b58
@ -94,6 +94,10 @@
|
||||
[_itemButton setHighlighted:highlighted];
|
||||
}
|
||||
|
||||
- (void) setItemName:(NSString *)itemName {
|
||||
[_itemSubView setItemName:itemName];
|
||||
}
|
||||
|
||||
- (void) itemButtonTapped {
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(tabBarItemSelected:)]) {
|
||||
[_delegate tabBarItemSelected:self];
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#import "MMCPSScrollView.h"
|
||||
#import <UIView-Overlay/UIView+Overlay.h>
|
||||
#import "NSString+HexColor.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
@interface TabBarPicker() <TabBarPickerSubItemsViewDelegate,TabBarItemDelegate>
|
||||
|
||||
@ -25,6 +26,7 @@
|
||||
@property (nonatomic, strong) NSMutableArray *tabBarItemsConstraints;
|
||||
@property (nonatomic, strong) TabBarItem *selectedTabBarItem;
|
||||
|
||||
@property (nonatomic, strong) UIView *separator;
|
||||
@property (nonatomic, strong) UIView *tabBarView;
|
||||
@property (nonatomic, strong) MMCPSScrollView *subItemScrollView;
|
||||
|
||||
@ -72,7 +74,11 @@
|
||||
|
||||
_tabBarView = [[UIView alloc] initForAutoLayout];
|
||||
|
||||
[self addSubview:_tabBarView];
|
||||
_separator = [[UIView alloc] initForAutoLayout];
|
||||
[_separator.layer setMasksToBounds:NO];
|
||||
[_separator setBackgroundColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.3]];
|
||||
|
||||
|
||||
|
||||
for (NSObject *item in items) {
|
||||
if (item && [item isKindOfClass:[TabBarItem class]]) {
|
||||
@ -93,6 +99,10 @@
|
||||
[_subItemScrollView setPageSize:1];
|
||||
|
||||
[self addSubview:_subItemScrollView];
|
||||
|
||||
[self addSubview:_tabBarView];
|
||||
|
||||
[self addSubview:_separator];
|
||||
}
|
||||
|
||||
[self updateConstraintsIfNeeded];
|
||||
@ -160,6 +170,10 @@
|
||||
[_tabBarView autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||
[_tabBarView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self];
|
||||
|
||||
[_separator autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview];
|
||||
[_separator autoSetDimension:ALDimensionHeight toSize:1];
|
||||
[_separator autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:_tabBarView];
|
||||
|
||||
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
|
||||
|
||||
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||
@ -394,11 +408,32 @@
|
||||
#pragma mark MMCPSScrollViewDelegate
|
||||
|
||||
- (void)scrollView:(MMCPSScrollView *)scrollView didScrollToPage:(NSUInteger)pageIndex {
|
||||
NSLog(@"The MMCPSScrollView is now on page %i.", pageIndex);
|
||||
if ([scrollView currentPage] > 0 && [scrollView currentPage] <= [_tabBarItems count]) {
|
||||
TabBarItem *selectedItem = [_tabBarItems objectAtIndex:[scrollView currentPage]-1];
|
||||
|
||||
for (TabBarItem *item in _tabBarItems) {
|
||||
if (![item isEqual:selectedItem]) {
|
||||
[item setHighlighted:NO];
|
||||
}
|
||||
else {
|
||||
[item setHighlighted:YES];
|
||||
}
|
||||
}
|
||||
|
||||
if (!_isShow) {
|
||||
[self show];
|
||||
}
|
||||
else {
|
||||
if(![_selectedTabBarItem isEqual:selectedItem]) {
|
||||
|
||||
}
|
||||
}
|
||||
_selectedTabBarItem = selectedItem;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollView:(MMCPSScrollView *)scrollView willScrollToPage:(NSUInteger)pageIndex {
|
||||
NSLog(@"The MMCPSScrollView is now going to page %i.", pageIndex);
|
||||
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@ -51,4 +51,5 @@ typedef NS_ENUM(NSInteger, TabBarPickerSubItemsViewType) {
|
||||
|
||||
- (instancetype) initWithType:(TabBarPickerSubItemsViewType) type subItems:(NSArray*) subItems needsLocalization:(BOOL) needsLocalization;
|
||||
|
||||
- (void) setItemName:(NSString *) itemName;
|
||||
@end
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
@property (nonatomic, strong) UILabel *switchBarLabel;
|
||||
@property (nonatomic, strong) UIButton *localizationButton;
|
||||
@property (nonatomic, strong) UIView *contentView;
|
||||
@property (nonatomic, strong) NSString *name;
|
||||
|
||||
@end
|
||||
|
||||
@ -45,7 +46,6 @@
|
||||
|
||||
_switchBarLabel = [[UILabel alloc] initForAutoLayout];
|
||||
[_switchBarLabel setTextColor:[@"999999" colorFromHex]];
|
||||
[_switchBarLabel setText:NSLocalizedString(@"Distance", @"")];
|
||||
[_switchBarView addSubview:_switchBarLabel];
|
||||
|
||||
_itemSwich = [[UISwitch alloc] initForAutoLayout];
|
||||
@ -65,7 +65,7 @@
|
||||
if (_needsLocalization) {
|
||||
|
||||
_localizationView = [[UIView alloc] initForAutoLayout];
|
||||
[_localizationView setBackgroundColor:[UIColor purpleColor]];
|
||||
[_localizationView setBackgroundColor:[UIColor whiteColor]];
|
||||
[_localizationView setAlpha:0];
|
||||
|
||||
_localizationButton = [[UIButton alloc] initForAutoLayout];
|
||||
@ -98,6 +98,8 @@
|
||||
|
||||
[UIView animateWithDuration:0.5 animations:^{
|
||||
[_localizationView setAlpha:[[NSNumber numberWithBool:[[SharedLocationManager sharedManager] localizationIsAuthorized]] floatValue]];
|
||||
[_itemSwich setUserInteractionEnabled:NO];
|
||||
[_itemSwich setOn:NO];
|
||||
}];
|
||||
|
||||
if (!_didSetupConstraints) {
|
||||
@ -188,4 +190,8 @@
|
||||
[super touchesBegan: touches withEvent:event];
|
||||
}
|
||||
|
||||
- (void) setItemName:(NSString *) itemName {
|
||||
[_switchBarLabel setText:itemName];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -45,7 +45,7 @@ typedef enum {
|
||||
// Time it takes to scroll to next page
|
||||
@property (nonatomic) CGFloat scrollingTime;
|
||||
|
||||
@property (nonatomic) NSUInteger currentPage;
|
||||
@property (nonatomic) NSInteger currentPage;
|
||||
|
||||
@property (nonatomic, assign) id<MMCPSScrollViewDelegate> MMCPSDelegate;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user