- Fix tab touches
This commit is contained in:
parent
4d7c6109a6
commit
dfd5420089
16
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
16
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
@ -49,8 +49,6 @@
|
|||||||
6115D515692E38D8D809451232B83C52 /* TabBarPickerSubItemsView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BDFBF8EAD1D91F7F7C98AE097F6AD54 /* TabBarPickerSubItemsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
6115D515692E38D8D809451232B83C52 /* TabBarPickerSubItemsView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BDFBF8EAD1D91F7F7C98AE097F6AD54 /* TabBarPickerSubItemsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
62AF98DE098B6AE453132CE1AA19765E /* POPDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = EB6215B243DFD151285F9B12CE2368A2 /* POPDefines.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
62AF98DE098B6AE453132CE1AA19765E /* POPDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = EB6215B243DFD151285F9B12CE2368A2 /* POPDefines.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
6354BF1C514445C33F9B65DD18205535 /* NSArray+PureLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 913E7306AD4E255661D418473382CF54 /* NSArray+PureLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
6354BF1C514445C33F9B65DD18205535 /* NSArray+PureLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 913E7306AD4E255661D418473382CF54 /* NSArray+PureLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
688DF0C01B833D0D00FE093C /* ToucheableScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 688DF0BE1B833D0D00FE093C /* ToucheableScrollView.h */; };
|
|
||||||
688DF0C11B833D0D00FE093C /* ToucheableScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 688DF0BF1B833D0D00FE093C /* ToucheableScrollView.m */; };
|
|
||||||
6BFFC7205011A11472F6457F6D6B489C /* POPAnimation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 24FD90CF8C651053BFFF6A3EAF117125 /* POPAnimation.mm */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };
|
6BFFC7205011A11472F6457F6D6B489C /* POPAnimation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 24FD90CF8C651053BFFF6A3EAF117125 /* POPAnimation.mm */; settings = {COMPILER_FLAGS = "-w -Xanalyzer -analyzer-disable-all-checks"; }; };
|
||||||
6C4B81E2699A8266AAB7C85824999897 /* POPSpringAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = A103939D06A87FED0BE43F0CF5F5056A /* POPSpringAnimation.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
6C4B81E2699A8266AAB7C85824999897 /* POPSpringAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = A103939D06A87FED0BE43F0CF5F5056A /* POPSpringAnimation.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
6DBFBBAB5805C21D1665893E655EA4FD /* POPDecayAnimationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 0092F18589478DBE2AE13D966D9CCD17 /* POPDecayAnimationInternal.h */; settings = {ATTRIBUTES = (Project, ); }; };
|
6DBFBBAB5805C21D1665893E655EA4FD /* POPDecayAnimationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 0092F18589478DBE2AE13D966D9CCD17 /* POPDecayAnimationInternal.h */; settings = {ATTRIBUTES = (Project, ); }; };
|
||||||
@ -228,8 +226,6 @@
|
|||||||
6474C99DA6F95FB4A031EA234BA3CF12 /* POPPropertyAnimation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = POPPropertyAnimation.h; path = pop/POPPropertyAnimation.h; sourceTree = "<group>"; };
|
6474C99DA6F95FB4A031EA234BA3CF12 /* POPPropertyAnimation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = POPPropertyAnimation.h; path = pop/POPPropertyAnimation.h; sourceTree = "<group>"; };
|
||||||
6682B426E85C9170F1FA5919B0BD809D /* TabBarPickerSubItemsView.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = TabBarPickerSubItemsView.m; sourceTree = "<group>"; };
|
6682B426E85C9170F1FA5919B0BD809D /* TabBarPickerSubItemsView.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = TabBarPickerSubItemsView.m; sourceTree = "<group>"; };
|
||||||
6805F6C4A24C2AAAB6A33C0A97652E03 /* POPAnimation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = POPAnimation.h; path = pop/POPAnimation.h; sourceTree = "<group>"; };
|
6805F6C4A24C2AAAB6A33C0A97652E03 /* POPAnimation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = POPAnimation.h; path = pop/POPAnimation.h; sourceTree = "<group>"; };
|
||||||
688DF0BE1B833D0D00FE093C /* ToucheableScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ToucheableScrollView.h; sourceTree = "<group>"; };
|
|
||||||
688DF0BF1B833D0D00FE093C /* ToucheableScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ToucheableScrollView.m; sourceTree = "<group>"; };
|
|
||||||
69A66B68532816A729F8D7B45A344A3D /* SharedLocationManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = SharedLocationManager.h; sourceTree = "<group>"; };
|
69A66B68532816A729F8D7B45A344A3D /* SharedLocationManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = SharedLocationManager.h; sourceTree = "<group>"; };
|
||||||
6C4407C962E1D98312FB510D7F5BA8D7 /* SharedLocationManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = SharedLocationManager.m; sourceTree = "<group>"; };
|
6C4407C962E1D98312FB510D7F5BA8D7 /* SharedLocationManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = SharedLocationManager.m; sourceTree = "<group>"; };
|
||||||
6E05779740DB7A4882324BB0CC77FE83 /* PureLayout.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = PureLayout.h; path = PureLayout/PureLayout/PureLayout.h; sourceTree = "<group>"; };
|
6E05779740DB7A4882324BB0CC77FE83 /* PureLayout.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = PureLayout.h; path = PureLayout/PureLayout/PureLayout.h; sourceTree = "<group>"; };
|
||||||
@ -502,19 +498,9 @@
|
|||||||
path = "Target Support Files/Pods-TabBarPicker_Example";
|
path = "Target Support Files/Pods-TabBarPicker_Example";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
688DF0BD1B833D0D00FE093C /* TouchableScrollView */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
688DF0BE1B833D0D00FE093C /* ToucheableScrollView.h */,
|
|
||||||
688DF0BF1B833D0D00FE093C /* ToucheableScrollView.m */,
|
|
||||||
);
|
|
||||||
path = TouchableScrollView;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
6F07576C2E19EA1A65B4E924DB9FD5C7 /* Vendor */ = {
|
6F07576C2E19EA1A65B4E924DB9FD5C7 /* Vendor */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
688DF0BD1B833D0D00FE093C /* TouchableScrollView */,
|
|
||||||
2B50D3C0ACD825270CCC306CD51D20E7 /* MMCPSScrollView */,
|
2B50D3C0ACD825270CCC306CD51D20E7 /* MMCPSScrollView */,
|
||||||
D32A21F857D4479FF01EE37CF833E9CD /* NSString+HexColor */,
|
D32A21F857D4479FF01EE37CF833E9CD /* NSString+HexColor */,
|
||||||
8AE381098F77067F0AD825096898C950 /* SharedLocationManager */,
|
8AE381098F77067F0AD825096898C950 /* SharedLocationManager */,
|
||||||
@ -821,7 +807,6 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
C3B4357DC8723B40B75036643935EBD7 /* MMCPSScrollView.h in Headers */,
|
C3B4357DC8723B40B75036643935EBD7 /* MMCPSScrollView.h in Headers */,
|
||||||
688DF0C01B833D0D00FE093C /* ToucheableScrollView.h in Headers */,
|
|
||||||
2A65286B5726E4AF0A5395E6B035F614 /* NSString+HexColor.h in Headers */,
|
2A65286B5726E4AF0A5395E6B035F614 /* NSString+HexColor.h in Headers */,
|
||||||
399306C358953571B5B236714BAC0F0B /* SharedLocationManager.h in Headers */,
|
399306C358953571B5B236714BAC0F0B /* SharedLocationManager.h in Headers */,
|
||||||
BA97F812224F556023C97037E1B9B768 /* TabBarItem.h in Headers */,
|
BA97F812224F556023C97037E1B9B768 /* TabBarItem.h in Headers */,
|
||||||
@ -1139,7 +1124,6 @@
|
|||||||
07501B134439D43A603B50365BAB8C36 /* NSString+HexColor.m in Sources */,
|
07501B134439D43A603B50365BAB8C36 /* NSString+HexColor.m in Sources */,
|
||||||
2D696A7493C3B7A7DC34C3857719B884 /* SharedLocationManager.m in Sources */,
|
2D696A7493C3B7A7DC34C3857719B884 /* SharedLocationManager.m in Sources */,
|
||||||
CCBEA17C33C968D4115035DFD75D03C7 /* TabBarItem.m in Sources */,
|
CCBEA17C33C968D4115035DFD75D03C7 /* TabBarItem.m in Sources */,
|
||||||
688DF0C11B833D0D00FE093C /* ToucheableScrollView.m in Sources */,
|
|
||||||
8684DD0504E7EC38B91A22B510C6A01D /* TabBarPicker-dummy.m in Sources */,
|
8684DD0504E7EC38B91A22B510C6A01D /* TabBarPicker-dummy.m in Sources */,
|
||||||
27612C6A0F69DAD74E0FEB17816B9E15 /* TabBarPicker.m in Sources */,
|
27612C6A0F69DAD74E0FEB17816B9E15 /* TabBarPicker.m in Sources */,
|
||||||
F959AAD4573A311BB8F79F1AF6BF166E /* TabBarPickerSubItemsView.m in Sources */,
|
F959AAD4573A311BB8F79F1AF6BF166E /* TabBarPickerSubItemsView.m in Sources */,
|
||||||
|
|||||||
@ -55,7 +55,7 @@
|
|||||||
//[_itemButton autoPinEdgesToSuperviewMargins];
|
//[_itemButton autoPinEdgesToSuperviewMargins];
|
||||||
if (!_didSetupConstraints) {
|
if (!_didSetupConstraints) {
|
||||||
[_itemButton autoCenterInSuperview];
|
[_itemButton autoCenterInSuperview];
|
||||||
[_itemButton autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self];
|
[_itemButton autoSetDimension:ALDimensionHeight toSize:44];
|
||||||
[_itemButton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
|
[_itemButton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
|
||||||
|
|
||||||
_didSetupConstraints = YES;
|
_didSetupConstraints = YES;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
#import "TabBarPicker.h"
|
#import "TabBarPicker.h"
|
||||||
#import <PureLayout/PureLayout.h>
|
#import <PureLayout/PureLayout.h>
|
||||||
#import "TabBarPickerSubItemsView.h"
|
#import "TabBarPickerSubItemsView.h"
|
||||||
#import "ToucheableScrollView.h"
|
#import "MMCPSScrollView.h"
|
||||||
#import <UIView-Overlay/UIView+Overlay.h>
|
#import <UIView-Overlay/UIView+Overlay.h>
|
||||||
#import "NSString+HexColor.h"
|
#import "NSString+HexColor.h"
|
||||||
|
|
||||||
@ -25,8 +25,8 @@
|
|||||||
@property (nonatomic, strong) NSMutableArray *tabBarItemsConstraints;
|
@property (nonatomic, strong) NSMutableArray *tabBarItemsConstraints;
|
||||||
@property (nonatomic, strong) TabBarItem *selectedTabBarItem;
|
@property (nonatomic, strong) TabBarItem *selectedTabBarItem;
|
||||||
|
|
||||||
@property (nonatomic, strong) ToucheableScrollView *subItemScrollView;
|
@property (nonatomic, strong) UIView *tabBarView;
|
||||||
@property (assign, nonatomic) int totalPages;
|
@property (nonatomic, strong) MMCPSScrollView *subItemScrollView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -70,19 +70,25 @@
|
|||||||
|
|
||||||
_tabBarItems = [[NSMutableArray alloc] init];
|
_tabBarItems = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
_tabBarView = [[UIView alloc] initForAutoLayout];
|
||||||
|
|
||||||
|
[self addSubview:_tabBarView];
|
||||||
|
|
||||||
for (NSObject *item in items) {
|
for (NSObject *item in items) {
|
||||||
if (item && [item isKindOfClass:[TabBarItem class]]) {
|
if (item && [item isKindOfClass:[TabBarItem class]]) {
|
||||||
|
|
||||||
[_tabBarItems addObject:item];
|
[_tabBarItems addObject:item];
|
||||||
[(TabBarItem*)item setDelegate:self];
|
[(TabBarItem*)item setDelegate:self];
|
||||||
[self addSubview:item];
|
[_tabBarView addSubview:item];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_subItemScrollView = [[ToucheableScrollView alloc] initForAutoLayout];
|
_subItemScrollView = [[MMCPSScrollView alloc] initForAutoLayout];
|
||||||
[_subItemScrollView setPagingEnabled:YES];
|
[_subItemScrollView setPagingEnabled:YES];
|
||||||
[_subItemScrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
|
[_subItemScrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
|
||||||
[_subItemScrollView setUserInteractionEnabled:YES];
|
[_subItemScrollView setUserInteractionEnabled:YES];
|
||||||
|
[_subItemScrollView setMMCPSDelegate:self];
|
||||||
|
[_subItemScrollView setPageSize:1];
|
||||||
|
|
||||||
[self addSubview:_subItemScrollView];
|
[self addSubview:_subItemScrollView];
|
||||||
}
|
}
|
||||||
@ -141,11 +147,17 @@
|
|||||||
case TabBarPickerPositionBottom:
|
case TabBarPickerPositionBottom:
|
||||||
default:{
|
default:{
|
||||||
|
|
||||||
_hideConstraint = [self autoPinEdgeToSuperviewMargin:ALEdgeBottom];
|
_hideConstraint = [self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.superview withOffset:299 relation:NSLayoutRelationEqual];
|
||||||
[self autoSetDimension:ALDimensionHeight toSize:44];
|
|
||||||
|
[self autoSetDimension:ALDimensionHeight toSize:343];
|
||||||
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:_layoutRelation];
|
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:_layoutRelation];
|
||||||
[self autoAlignAxisToSuperviewMarginAxis:ALAxisVertical];
|
[self autoAlignAxisToSuperviewMarginAxis:ALAxisVertical];
|
||||||
|
|
||||||
|
[_tabBarView autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview];
|
||||||
|
[_tabBarView autoSetDimension:ALDimensionHeight toSize:44];
|
||||||
|
[_tabBarView autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||||
|
[_tabBarView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self];
|
||||||
|
|
||||||
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
|
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
|
||||||
|
|
||||||
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
@ -156,11 +168,12 @@
|
|||||||
[_subItemScrollView autoSetDimension:ALDimensionHeight toSize:343];
|
[_subItemScrollView autoSetDimension:ALDimensionHeight toSize:343];
|
||||||
[_subItemScrollView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:[_tabBarItems firstObject]];
|
[_subItemScrollView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:[_tabBarItems firstObject]];
|
||||||
[_subItemScrollView autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
[_subItemScrollView autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||||
|
[_subItemScrollView setSegmentSize:[[UIScreen mainScreen] bounds].size.width ];
|
||||||
|
[_subItemScrollView setType:MMCPSScrollHorizontal];
|
||||||
|
|
||||||
if ([_tabBarItems count] > 0) {
|
if ([_tabBarItems count] > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
TabBarItem *prevItem;
|
|
||||||
for (TabBarItem *item in _tabBarItems) {
|
for (TabBarItem *item in _tabBarItems) {
|
||||||
|
|
||||||
if ([item itemSubView]) {
|
if ([item itemSubView]) {
|
||||||
@ -193,36 +206,18 @@
|
|||||||
|
|
||||||
[_subItemSelectors addObject:[item itemSubView]];
|
[_subItemSelectors addObject:[item itemSubView]];
|
||||||
|
|
||||||
if (!prevItem) {
|
|
||||||
// Align to contentView
|
|
||||||
[pageLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft];
|
|
||||||
} else {
|
|
||||||
// Align to prev label
|
|
||||||
[pageLabel autoConstrainAttribute:ALAttributeLeading toAttribute:ALAttributeTrailing ofView:prevLabel];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == pages - 1) {
|
|
||||||
// Last page
|
|
||||||
[pageLabel autoPinEdgeToSuperviewEdge:ALEdgeRight];
|
|
||||||
}
|
|
||||||
|
|
||||||
prevItem = item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[_subItemScrollView setPageSize:1];
|
[_subItemScrollView setPageSize:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
//[_subItemSelectors autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:0 insetSpacing:YES matchedSizes:YES];
|
[_subItemSelectors autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:0 insetSpacing:YES matchedSizes:YES];
|
||||||
|
|
||||||
//[[_subItemSelectors firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
|
||||||
|
|
||||||
//[_subItemScrollView layoutIfNeeded];
|
|
||||||
|
|
||||||
|
[[_subItemSelectors firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_didSetupConstraints = YES;
|
_didSetupConstraints = YES;
|
||||||
|
|
||||||
[self updateConstraintsIfNeeded];
|
[self updateConstraintsIfNeeded];
|
||||||
@ -300,7 +295,7 @@
|
|||||||
default: {
|
default: {
|
||||||
[_hideConstraint autoRemove];
|
[_hideConstraint autoRemove];
|
||||||
|
|
||||||
_showConstraint = [self autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:_subItemScrollView.frame.size.height];
|
_showConstraint = [self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.superview withOffset:0 relation:NSLayoutRelationEqual];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,7 +344,7 @@
|
|||||||
default: {
|
default: {
|
||||||
[_showConstraint autoRemove];
|
[_showConstraint autoRemove];
|
||||||
|
|
||||||
_hideConstraint = [self autoPinEdgeToSuperviewMargin:ALEdgeBottom];
|
_hideConstraint = [self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.superview withOffset:299 relation:NSLayoutRelationEqual];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,7 +384,7 @@
|
|||||||
}
|
}
|
||||||
_selectedTabBarItem = selectedItem;
|
_selectedTabBarItem = selectedItem;
|
||||||
|
|
||||||
[_subItemScrollView scrollToPage:[_tabBarItems indexOfObject:_selectedTabBarItem]+1];
|
[_subItemScrollView scrollToPage:[_tabBarItems indexOfObject:_selectedTabBarItem]];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
@property (nonatomic, strong) UISwitch *itemSwich;
|
@property (nonatomic, strong) UISwitch *itemSwich;
|
||||||
@property (nonatomic, strong) UILabel *switchBarLabel;
|
@property (nonatomic, strong) UILabel *switchBarLabel;
|
||||||
@property (nonatomic, strong) UIButton *localizationButton;
|
@property (nonatomic, strong) UIButton *localizationButton;
|
||||||
|
@property (nonatomic, strong) UIView *contentView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -54,7 +55,11 @@
|
|||||||
[_itemSwich.layer setCornerRadius:_itemSwich.frame.size.height/2];
|
[_itemSwich.layer setCornerRadius:_itemSwich.frame.size.height/2];
|
||||||
[_itemSwich setUserInteractionEnabled:YES];
|
[_itemSwich setUserInteractionEnabled:YES];
|
||||||
[_itemSwich addTarget:self action:@selector(changeSwitch:) forControlEvents:UIControlEventValueChanged];
|
[_itemSwich addTarget:self action:@selector(changeSwitch:) forControlEvents:UIControlEventValueChanged];
|
||||||
[_switchBarView addSubview:_itemSwich];
|
|
||||||
|
_contentView = [[UIView alloc] initForAutoLayout];
|
||||||
|
|
||||||
|
|
||||||
|
[self addSubview:_contentView];
|
||||||
|
|
||||||
if (_needsLocalization) {
|
if (_needsLocalization) {
|
||||||
|
|
||||||
@ -62,7 +67,6 @@
|
|||||||
[_localizationView setBackgroundColor:[UIColor purpleColor]];
|
[_localizationView setBackgroundColor:[UIColor purpleColor]];
|
||||||
[_localizationView setAlpha:0];
|
[_localizationView setAlpha:0];
|
||||||
|
|
||||||
|
|
||||||
_localizationButton = [[UIButton alloc] initForAutoLayout];
|
_localizationButton = [[UIButton alloc] initForAutoLayout];
|
||||||
[_localizationButton setTitle:NSLocalizedString(@"ATTIVA LOCALIZZAZIONE DISPOSITIVO", @"") forState:UIControlStateNormal];
|
[_localizationButton setTitle:NSLocalizedString(@"ATTIVA LOCALIZZAZIONE DISPOSITIVO", @"") forState:UIControlStateNormal];
|
||||||
[_localizationButton addTarget:self action:@selector(openSettings) forControlEvents:UIControlEventTouchUpInside];
|
[_localizationButton addTarget:self action:@selector(openSettings) forControlEvents:UIControlEventTouchUpInside];
|
||||||
@ -75,16 +79,12 @@
|
|||||||
|
|
||||||
[_localizationView addSubview:_localizationButton];
|
[_localizationView addSubview:_localizationButton];
|
||||||
|
|
||||||
[self addSubview:_localizationView];
|
[_contentView addSubview:_localizationView];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*_subItems = [[NSMutableArray alloc] init];
|
|
||||||
for (NSObject *subItem in subItems) {
|
|
||||||
if ([subItem isKindOfClass:[TabBarSubItem class]]) {
|
|
||||||
[_subItems addObject:subItem];
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
[self addSubview:_switchBarView];
|
[self addSubview:_switchBarView];
|
||||||
|
|
||||||
|
[_switchBarView addSubview:_itemSwich];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self updateConstraintsIfNeeded];
|
[self updateConstraintsIfNeeded];
|
||||||
@ -115,22 +115,34 @@
|
|||||||
[_itemSwich autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:_switchBarView withOffset:-20];
|
[_itemSwich autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:_switchBarView withOffset:-20];
|
||||||
[_itemSwich autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
[_itemSwich autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
|
|
||||||
[_localizationView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:_itemSwich withOffset:4];
|
[_contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:_switchBarView];
|
||||||
[_localizationView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self];
|
[_contentView autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
|
||||||
[_localizationView autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
|
[_contentView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self];
|
||||||
|
[_contentView autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||||
|
|
||||||
|
if (_needsLocalization) {
|
||||||
|
|
||||||
|
[_localizationView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:_contentView];
|
||||||
|
|
||||||
|
[_localizationView autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:_contentView];
|
||||||
|
[_localizationView autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
|
[_localizationView autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||||
|
|
||||||
[_localizationButton autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
[_localizationButton autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
[_localizationButton autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
[_localizationButton autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||||
[_localizationButton autoSetDimension:ALDimensionHeight toSize:44 relation:NSLayoutRelationLessThanOrEqual];
|
[_localizationButton autoSetDimension:ALDimensionHeight toSize:44 relation:NSLayoutRelationLessThanOrEqual];
|
||||||
[_localizationButton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self withMultiplier:0.8];
|
[_localizationButton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self withMultiplier:0.8];
|
||||||
|
}
|
||||||
_didSetupConstraints = YES;
|
_didSetupConstraints = YES;
|
||||||
}
|
}
|
||||||
NSLog(@"%f %f",self.frame.size.width,self.frame.size.height);
|
|
||||||
NSLog(@"%f %f",_switchBarView.frame.size.width,_switchBarView.frame.size.height);
|
|
||||||
[_localizationButton.layer setCornerRadius:_localizationButton.frame.size.height/2];
|
[_localizationButton.layer setCornerRadius:_localizationButton.frame.size.height/2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setBackgroundColor:(UIColor *)backgroundColor {
|
||||||
|
[_contentView setBackgroundColor:backgroundColor];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) enableLocalizationWithView:(UIView *) localizationView {
|
- (void) enableLocalizationWithView:(UIView *) localizationView {
|
||||||
_needsLocalization = YES;
|
_needsLocalization = YES;
|
||||||
_localizationView = localizationView;
|
_localizationView = localizationView;
|
||||||
|
|||||||
@ -324,20 +324,19 @@
|
|||||||
{
|
{
|
||||||
// If not dragging, send event to next responder
|
// If not dragging, send event to next responder
|
||||||
if (!self.dragging) {
|
if (!self.dragging) {
|
||||||
|
if ([self.nextResponder respondsToSelector:@selector(touchesEnded:withEvent:)]) {
|
||||||
|
[self.nextResponder touchesEnded: touches withEvent:event];
|
||||||
|
}
|
||||||
|
if ([self.nextResponder.nextResponder respondsToSelector:@selector(touchesEnded:withEvent:)]) {
|
||||||
[self.nextResponder.nextResponder touchesEnded: touches withEvent:event];
|
[self.nextResponder.nextResponder touchesEnded: touches withEvent:event];
|
||||||
}
|
}
|
||||||
else
|
if ([self.nextResponder.nextResponder.nextResponder respondsToSelector:@selector(touchesEnded:withEvent:)]) {
|
||||||
[super touchesEnded: touches withEvent: event];
|
[self.nextResponder.nextResponder.nextResponder touchesEnded: touches withEvent:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
[super touchesEnded: touches withEvent: event];
|
||||||
|
|
||||||
if (!self.dragging) {
|
|
||||||
[self.nextResponder.nextResponder touchesBegan: touches withEvent:event];
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
[super touchesBegan: touches withEvent:event];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
//
|
|
||||||
// ToucheableScrollView.m
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Mario Nolassi on 11/16/11.
|
|
||||||
// Copyright (c) 2011 meedori. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@interface ToucheableScrollView : UIScrollView
|
|
||||||
|
|
||||||
@end
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
//
|
|
||||||
// ToucheableScrollView.m
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Created by Mario Nolassi on 11/16/11.
|
|
||||||
// Copyright (c) 2011 meedori. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "ToucheableScrollView.h"
|
|
||||||
|
|
||||||
@implementation ToucheableScrollView
|
|
||||||
|
|
||||||
- (id)initWithFrame:(CGRect)frame
|
|
||||||
{
|
|
||||||
self = [super initWithFrame:frame];
|
|
||||||
|
|
||||||
if (self) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
|
|
||||||
{
|
|
||||||
// If not dragging, send event to next responder
|
|
||||||
if (!self.dragging) {
|
|
||||||
if ([self.nextResponder respondsToSelector:@selector(touchesEnded:withEvent:)]) {
|
|
||||||
[self.nextResponder touchesEnded: touches withEvent:event];
|
|
||||||
}
|
|
||||||
if ([self.nextResponder.nextResponder respondsToSelector:@selector(touchesEnded:withEvent:)]) {
|
|
||||||
[self.nextResponder.nextResponder touchesEnded: touches withEvent:event];
|
|
||||||
}
|
|
||||||
if ([self.nextResponder.nextResponder.nextResponder respondsToSelector:@selector(touchesEnded:withEvent:)]) {
|
|
||||||
[self.nextResponder.nextResponder.nextResponder touchesEnded: touches withEvent:event];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[super touchesEnded: touches withEvent: event];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user