- Fixes
This commit is contained in:
parent
c2be9705ac
commit
603962375e
1
Example/Pods/Headers/Private/TabBarPicker/TabBarPickerSubItemsView.h
generated
Symbolic link
1
Example/Pods/Headers/Private/TabBarPicker/TabBarPickerSubItemsView.h
generated
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../../../Pod/Classes/TabBarPickerSubItemsView.h
|
||||||
1
Example/Pods/Headers/Public/TabBarPicker/TabBarPickerSubItemsView.h
generated
Symbolic link
1
Example/Pods/Headers/Public/TabBarPicker/TabBarPickerSubItemsView.h
generated
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../../../Pod/Classes/TabBarPickerSubItemsView.h
|
||||||
2780
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
2780
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@
|
|||||||
buildForAnalyzing = "YES">
|
buildForAnalyzing = "YES">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "66A365F03E2E5FD04D4DAC69"
|
BlueprintIdentifier = "F1DAA46C7CBB0FB9B92A7891"
|
||||||
BuildableName = "TabBarPicker.bundle"
|
BuildableName = "TabBarPicker.bundle"
|
||||||
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker-TabBarPicker"
|
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker-TabBarPicker"
|
||||||
ReferencedContainer = "container:Pods.xcodeproj">
|
ReferencedContainer = "container:Pods.xcodeproj">
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
buildForAnalyzing = "YES">
|
buildForAnalyzing = "YES">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "4F73FDE94825965417E35D5A"
|
BlueprintIdentifier = "FD042F8BAEE7119C1EA51707"
|
||||||
BuildableName = "TabBarPicker.framework"
|
BuildableName = "TabBarPicker.framework"
|
||||||
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker"
|
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker"
|
||||||
ReferencedContainer = "container:Pods.xcodeproj">
|
ReferencedContainer = "container:Pods.xcodeproj">
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
buildForAnalyzing = "YES">
|
buildForAnalyzing = "YES">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "7C0EACB3AF64706AA504E8BE"
|
BlueprintIdentifier = "AFD4CD498974811C4E61A02F"
|
||||||
BuildableName = "TabBarPicker.bundle"
|
BuildableName = "TabBarPicker.bundle"
|
||||||
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker-TabBarPicker"
|
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker-TabBarPicker"
|
||||||
ReferencedContainer = "container:Pods.xcodeproj">
|
ReferencedContainer = "container:Pods.xcodeproj">
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
buildForAnalyzing = "YES">
|
buildForAnalyzing = "YES">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "113B2CE1962FE34F95B1D5AD"
|
BlueprintIdentifier = "B372419045A1236C95998EEE"
|
||||||
BuildableName = "TabBarPicker.framework"
|
BuildableName = "TabBarPicker.framework"
|
||||||
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker"
|
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker"
|
||||||
ReferencedContainer = "container:Pods.xcodeproj">
|
ReferencedContainer = "container:Pods.xcodeproj">
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#import "TabBarItem.h"
|
#import "TabBarItem.h"
|
||||||
#import "TabBarPicker.h"
|
#import "TabBarPicker.h"
|
||||||
|
#import "TabBarPickerSubItemsView.h"
|
||||||
#import "TabBarSubItem.h"
|
#import "TabBarSubItem.h"
|
||||||
|
|
||||||
FOUNDATION_EXPORT double TabBarPickerVersionNumber;
|
FOUNDATION_EXPORT double TabBarPickerVersionNumber;
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#import "TabBarItem.h"
|
#import "TabBarItem.h"
|
||||||
#import "TabBarPicker.h"
|
#import "TabBarPicker.h"
|
||||||
|
#import "TabBarPickerSubItemsView.h"
|
||||||
#import "TabBarSubItem.h"
|
#import "TabBarSubItem.h"
|
||||||
|
|
||||||
FOUNDATION_EXPORT double TabBarPickerVersionNumber;
|
FOUNDATION_EXPORT double TabBarPickerVersionNumber;
|
||||||
|
|||||||
@ -59,7 +59,10 @@
|
|||||||
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
||||||
|
|
||||||
tabbar = [[TabBarPicker alloc] initWithTabBarItems:@[location,calendar,type,price,allergen] forPosition:TabBarPickerPositionBottom];
|
tabbar = [[TabBarPicker alloc] initWithTabBarItems:@[location,calendar,type,price,allergen] forPosition:TabBarPickerPositionBottom];
|
||||||
|
|
||||||
[tabbar setBackgroundColor:[UIColor whiteColor]];
|
[tabbar setBackgroundColor:[UIColor whiteColor]];
|
||||||
|
|
||||||
|
[tabbar addItem:allergen];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -70,17 +73,7 @@
|
|||||||
|
|
||||||
[contentView addSubview:tabbar];
|
[contentView addSubview:tabbar];
|
||||||
|
|
||||||
/*[tabbar autoPinEdgesToSuperviewMarginsExcludingEdge:ALEdgeTop];
|
|
||||||
tabbar ali
|
|
||||||
[tabbar autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:50 relation:NSLayoutRelationGreaterThanOrEqual];
|
|
||||||
[tabbar autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:50 relation:NSLayoutRelationGreaterThanOrEqual];
|
|
||||||
*/
|
|
||||||
|
|
||||||
NSLog(@"%f %f",tabbar.frame.size.width,tabbar.frame.size.height);
|
|
||||||
|
|
||||||
self.view = contentView;
|
self.view = contentView;
|
||||||
|
|
||||||
[self.view setNeedsUpdateConstraints];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidLoad
|
- (void)viewDidLoad
|
||||||
@ -89,7 +82,25 @@
|
|||||||
|
|
||||||
//[self.view setBackgroundColor:[UIColor lightGrayColor]];
|
//[self.view setBackgroundColor:[UIColor lightGrayColor]];
|
||||||
// Do any additional setup after loading the view, typically from a nib.
|
// Do any additional setup after loading the view, typically from a nib.
|
||||||
|
[super updateViewConstraints];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) viewDidAppear:(BOOL)animated {
|
||||||
|
|
||||||
|
TabBarSubItem *subItem1 = [TabBarSubItem tabBarSubItemWithName:@"Peppe"];
|
||||||
|
TabBarSubItem *subItem2 = [TabBarSubItem tabBarSubItemWithName:@"Peppe1"];
|
||||||
|
TabBarSubItem *subItem3 = [TabBarSubItem tabBarSubItemWithName:@"Peppe2"];
|
||||||
|
TabBarSubItem *subItem4 = [TabBarSubItem tabBarSubItemWithName:@"Peppe3"];
|
||||||
|
TabBarSubItem *subItem5 = [TabBarSubItem tabBarSubItemWithName:@"Peppe4"];
|
||||||
|
TabBarSubItem *subItem6 = [TabBarSubItem tabBarSubItemWithName:@"Peppe5"];
|
||||||
|
TabBarSubItem *subItem7 = [TabBarSubItem tabBarSubItemWithName:@"Peppe6"];
|
||||||
|
|
||||||
|
TabBarItem *allergen = [[TabBarItem alloc] initWithSubItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7]];
|
||||||
|
[allergen setItemName:@"Allergen"];
|
||||||
|
[allergen setImage:[UIImage imageNamed:@"allergen_off"]];
|
||||||
|
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
||||||
|
|
||||||
|
[tabbar addItem:allergen];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
|
|||||||
@ -9,6 +9,16 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "TabBarSubItem.h"
|
#import "TabBarSubItem.h"
|
||||||
|
|
||||||
|
@class TabBarItem;
|
||||||
|
|
||||||
|
@protocol TabBarItemDelegate <NSObject>
|
||||||
|
|
||||||
|
@required
|
||||||
|
|
||||||
|
- (void) tabBarItemSelected:(TabBarItem*) selectedItem;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface TabBarItem : UIView
|
@interface TabBarItem : UIView
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,6 +37,10 @@
|
|||||||
* Represents the sub items that appeare when you select the item in picker.
|
* Represents the sub items that appeare when you select the item in picker.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) NSMutableArray *subItems;
|
@property (nonatomic, strong) NSMutableArray *subItems;
|
||||||
|
/**
|
||||||
|
* <#Description#>
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) id<TabBarItemDelegate> delegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <#Description#>
|
* <#Description#>
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
@interface TabBarItem()
|
@interface TabBarItem()
|
||||||
|
|
||||||
|
|
||||||
|
@property (nonatomic, strong) UIButton *itemButton;
|
||||||
@property (nonatomic) UIDeviceOrientation orientation;
|
@property (nonatomic) UIDeviceOrientation orientation;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -21,9 +23,13 @@
|
|||||||
self = [self initForAutoLayout];
|
self = [self initForAutoLayout];
|
||||||
if (self) {
|
if (self) {
|
||||||
NSAssert(array, @"SubItemsArray cannot be nil");
|
NSAssert(array, @"SubItemsArray cannot be nil");
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];
|
||||||
|
|
||||||
_orientation = [[UIDevice currentDevice] orientation];
|
_orientation = [[UIDevice currentDevice] orientation];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver: self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];
|
|
||||||
|
_itemButton = [[UIButton alloc] initForAutoLayout];
|
||||||
|
|
||||||
|
[self addSubview:_itemButton];
|
||||||
|
|
||||||
_subItems = [[NSMutableArray alloc] init];
|
_subItems = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
@ -36,11 +42,26 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) layoutSubviews {
|
||||||
|
|
||||||
|
[_itemButton autoPinEdgesToSuperviewMargins];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void)deviceOrientationDidChange:(NSNotification *)notification {
|
- (void)deviceOrientationDidChange:(NSNotification *)notification {
|
||||||
//Obtain current device orientation
|
//Obtain current device orientation
|
||||||
_orientation = [[UIDevice currentDevice] orientation];
|
_orientation = [[UIDevice currentDevice] orientation];
|
||||||
|
|
||||||
|
[self layoutSubviews];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setImage:(UIImage *)image {
|
||||||
|
[_itemButton setImage:image forState:UIControlStateNormal];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setSelectedImage:(UIImage *)selectedImage {
|
||||||
|
|
||||||
|
[_itemButton setImage:selectedImage forState:UIControlStateSelected];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -10,26 +10,33 @@
|
|||||||
#import "TabbarItem.h"
|
#import "TabbarItem.h"
|
||||||
#import "TabBarSubItem.h"
|
#import "TabBarSubItem.h"
|
||||||
|
|
||||||
typedef enum
|
typedef NS_ENUM(NSInteger, TabBarPickerPosition) {
|
||||||
{
|
|
||||||
// Informational
|
// Informational
|
||||||
TabBarPickerPositionLeft,
|
TabBarPickerPositionLeft,
|
||||||
TabBarPickerPositionRight,
|
TabBarPickerPositionRight,
|
||||||
TabBarPickerPositionBottom
|
TabBarPickerPositionBottom,
|
||||||
|
TabBarPickerPositionTop
|
||||||
|
|
||||||
} TabBarPickerPosition;
|
};
|
||||||
|
|
||||||
@interface TabBarPicker : UIView
|
@interface TabBarPicker : UIView
|
||||||
|
|
||||||
@property (nonatomic, strong) NSMutableArray *tabBarItems;
|
@property (nonatomic, strong, readonly) NSMutableArray *tabBarItems;
|
||||||
@property (nonatomic, readonly) CGSize tabBarSize;
|
@property (nonatomic, readonly) CGSize tabBarSize;
|
||||||
@property (nonatomic) TabBarPickerPosition position;
|
@property (nonatomic, readonly) TabBarPickerPosition position;
|
||||||
|
@property (nonatomic, readonly) NSLayoutRelation layoutRelation;
|
||||||
|
@property (nonatomic) CGFloat paddingLeft;
|
||||||
|
@property (nonatomic) CGFloat paddingRight;
|
||||||
|
@property (nonatomic) CGFloat paddingTop;
|
||||||
|
@property (nonatomic) CGFloat paddingBottom;
|
||||||
|
@property (nonatomic) CGFloat itemSpacing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init TabBarPicker with items. When is selected an item the picher show down subitems.
|
* Init TabBarPicker with items. When is selected an item the picher show down subitems.
|
||||||
* By default when one of more subItems are selected the selected item become selected.
|
* By default when one of more subItems are selected the selected item become selected.
|
||||||
* By default the tabBar size is max screen width and 100px height
|
* By default the tabBar size is max screen width and 100px height
|
||||||
* The picker size is dinamically based the max subitems of items.
|
* The picker size is dinamically based the max subitems of items.
|
||||||
|
* For this method is used NSLayoutRelationEqual as NSLayoutRelation configuration.
|
||||||
*
|
*
|
||||||
* @param items Represents tab bar items. That array cannot be nil.
|
* @param items Represents tab bar items. That array cannot be nil.
|
||||||
*
|
*
|
||||||
@ -43,6 +50,26 @@ typedef enum
|
|||||||
*/
|
*/
|
||||||
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position;
|
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init TabBarPicker with items. When is selected an item the picher show down subitems.
|
||||||
|
* By default when one of more subItems are selected the selected item become selected.
|
||||||
|
* By default the tabBar size is max screen width and 100px height
|
||||||
|
* The picker size is dinamically based the max subitems of items.
|
||||||
|
*
|
||||||
|
* @param items Represents tab bar items. That array cannot be nil.
|
||||||
|
*
|
||||||
|
* @param position Represents the posizion in the Screen:
|
||||||
|
* - TabBarPickerPositionLeft : Is positioned in vertical on left of the screen and shows the picker at its right
|
||||||
|
* - TabBarPickerPositionRight : Is positioned in vertical on right of the screen and shows the picker at its left
|
||||||
|
* - TabBarPickerPositionBottom : Is positioned in horizontal on bottom of the screen and shows the picker at its top
|
||||||
|
* - TabBarPickerPositionTop : Is positioned in horizontal on top of the screen and shows the picker at its bottom
|
||||||
|
*
|
||||||
|
* @param relation Represents NSLayoutRelation for TabBar layout.
|
||||||
|
*
|
||||||
|
* @return raturn instance of TabBarPicker object.
|
||||||
|
*/
|
||||||
|
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position andNSLayoutRelation:(NSLayoutRelation) relation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init TabBarPicker with items. When is selected an item the picher show down subitems.
|
* Init TabBarPicker with items. When is selected an item the picher show down subitems.
|
||||||
* By default when one of more subItems are selected the selected item become selected.
|
* By default when one of more subItems are selected the selected item become selected.
|
||||||
@ -58,8 +85,17 @@ typedef enum
|
|||||||
* - TabBarPickerPositionBottom : Is positioned in horizontal on bottom of the screen and shows the picker at its top
|
* - TabBarPickerPositionBottom : Is positioned in horizontal on bottom of the screen and shows the picker at its top
|
||||||
* - TabBarPickerPositionTop : Is positioned in horizontal on top of the screen and shows the picker at its bottom
|
* - TabBarPickerPositionTop : Is positioned in horizontal on top of the screen and shows the picker at its bottom
|
||||||
*
|
*
|
||||||
|
* @param relation Represents NSLayoutRelation for TabBar layout.
|
||||||
|
*
|
||||||
* @return raturn instance of TabBarPicker object.
|
* @return raturn instance of TabBarPicker object.
|
||||||
*/
|
*/
|
||||||
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position;
|
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation) relation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <#Description#>
|
||||||
|
*
|
||||||
|
* @param item <#item description#>
|
||||||
|
*/
|
||||||
|
- (void) addItem:(TabBarItem*) item;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -8,11 +8,9 @@
|
|||||||
|
|
||||||
#import "TabBarPicker.h"
|
#import "TabBarPicker.h"
|
||||||
#import <PureLayout/PureLayout.h>
|
#import <PureLayout/PureLayout.h>
|
||||||
|
#import "TabBarPickerSubItemsView.h"
|
||||||
|
|
||||||
#define tabBarSizeVertical CGSizeMake()
|
@interface TabBarPicker() <TabBarItemDelegate>
|
||||||
|
|
||||||
|
|
||||||
@interface TabBarPicker()
|
|
||||||
|
|
||||||
@property (nonatomic) UIDeviceOrientation orientation;
|
@property (nonatomic) UIDeviceOrientation orientation;
|
||||||
|
|
||||||
@ -22,19 +20,33 @@
|
|||||||
|
|
||||||
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position {
|
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position {
|
||||||
|
|
||||||
return [self initWithTabBarItems:items withTabBarSize:CGSizeZero forPosition:position];
|
return [self initWithTabBarItems:items withTabBarSize:CGSizeZero forPosition:position andNSLayoutRelation:NSLayoutRelationEqual];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position {
|
- (instancetype) initWithTabBarItems:(NSArray *)items forPosition:(TabBarPickerPosition)position andNSLayoutRelation:(NSLayoutRelation)relation {
|
||||||
|
|
||||||
|
return [self initWithTabBarItems:items withTabBarSize:CGSizeZero forPosition:position andNSLayoutRelation:relation];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype) initWithTabBarItems:(NSArray*) items withTabBarSize:(CGSize) size forPosition:(TabBarPickerPosition) position andNSLayoutRelation:(NSLayoutRelation)relation {
|
||||||
|
|
||||||
self = [self initForAutoLayout];
|
self = [self initForAutoLayout];
|
||||||
if (self) {
|
if (self) {
|
||||||
|
_itemSpacing = 10;
|
||||||
|
_paddingLeft = 0;
|
||||||
|
_paddingRight = 0;
|
||||||
|
_paddingTop = 0;
|
||||||
|
_paddingBottom = 0;
|
||||||
|
_layoutRelation = relation;
|
||||||
|
|
||||||
|
_position = position;
|
||||||
|
|
||||||
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
|
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];
|
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];
|
||||||
|
|
||||||
NSAssert(items, @"TabBar Items array cannot be nil!");
|
NSAssert(items, @"TabBar Items array cannot be nil!");
|
||||||
|
|
||||||
if (CGSizeEqualToSize(size, CGSizeZero)) {
|
if (CGSizeEqualToSize(size, CGSizeZero)) {
|
||||||
@ -42,26 +54,91 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_tabBarItems = [[NSMutableArray alloc] init];
|
_tabBarItems = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
for (NSObject *item in items) {
|
for (NSObject *item in items) {
|
||||||
if ([item isKindOfClass:[TabBarItem class]]) {
|
[self addItem:item];
|
||||||
[_tabBarItems addObject:item];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[self setNeedsUpdateConstraints];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) layoutSubviews {
|
- (void) layoutSubviews {
|
||||||
|
|
||||||
[self autoSetDimension:ALDimensionHeight toSize:44];
|
switch (_position) {
|
||||||
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview];
|
case TabBarPickerPositionLeft:{
|
||||||
[self autoPinEdgeToSuperviewMargin:ALEdgeBottom];
|
[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:20];
|
||||||
|
[self autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:0];
|
||||||
|
[self autoSetDimension:ALDimensionWidth toSize:44];
|
||||||
|
[self autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.superview withOffset:0 relation:_layoutRelation];
|
||||||
|
[self autoAlignAxisToSuperviewMarginAxis:ALAxisHorizontal];
|
||||||
|
|
||||||
|
[_tabBarItems autoSetViewsDimension:ALDimensionWidth toSize:44.0];
|
||||||
|
|
||||||
|
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisVertical alignedTo:ALAttributeVertical withFixedSpacing:_itemSpacing insetSpacing:YES matchedSizes:YES];
|
||||||
|
|
||||||
|
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TabBarPickerPositionRight:{
|
||||||
|
[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:20];
|
||||||
|
[self autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:0];
|
||||||
|
[self autoSetDimension:ALDimensionWidth toSize:44];
|
||||||
|
[self autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.superview withOffset:0 relation:_layoutRelation];
|
||||||
|
[self autoAlignAxisToSuperviewMarginAxis:ALAxisHorizontal];
|
||||||
|
|
||||||
|
[_tabBarItems autoSetViewsDimension:ALDimensionWidth toSize:44.0];
|
||||||
|
|
||||||
|
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisVertical alignedTo:ALAttributeVertical withFixedSpacing:_itemSpacing insetSpacing:YES matchedSizes:YES];
|
||||||
|
|
||||||
|
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisVertical];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TabBarPickerPositionTop:{
|
||||||
|
[self autoPinEdgeToSuperviewMargin:ALEdgeTop];
|
||||||
|
[self autoSetDimension:ALDimensionHeight toSize:44];
|
||||||
|
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:_layoutRelation];
|
||||||
|
[self autoAlignAxisToSuperviewMarginAxis:ALAxisVertical];
|
||||||
|
|
||||||
|
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
|
||||||
|
|
||||||
|
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:_itemSpacing insetSpacing:YES matchedSizes:YES];
|
||||||
|
|
||||||
|
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TabBarPickerPositionBottom:
|
||||||
|
default:{
|
||||||
|
[self autoPinEdgeToSuperviewMargin:ALEdgeBottom];
|
||||||
|
[self autoSetDimension:ALDimensionHeight toSize:44];
|
||||||
|
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:_layoutRelation];
|
||||||
|
[self autoAlignAxisToSuperviewMarginAxis:ALAxisVertical];
|
||||||
|
|
||||||
|
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
|
||||||
|
|
||||||
|
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:0 insetSpacing:YES matchedSizes:YES];
|
||||||
|
|
||||||
|
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
[self updateConstraints];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setPosition:(TabBarPickerPosition)position {
|
||||||
|
_position = position;
|
||||||
|
|
||||||
for (TabBarItem *item in _tabBarItems) {
|
if (self.superview) {
|
||||||
|
[self removeConstraints:self.constraints];
|
||||||
|
|
||||||
|
for (TabBarItem *item in _tabBarItems) {
|
||||||
|
[item removeConstraints:item.constraints];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self layoutSubviews];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +149,29 @@
|
|||||||
[self layoutSubviews];
|
[self layoutSubviews];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) addItem:(TabBarItem*) item {
|
||||||
|
if (item && [item isKindOfClass:[TabBarItem class]]) {
|
||||||
|
|
||||||
|
NSLog(@"%@",self.constraints);
|
||||||
|
|
||||||
|
[_tabBarItems addObject:item];
|
||||||
|
[item setBackgroundColor:[UIColor lightGrayColor]];
|
||||||
|
[item setDelegate:self];
|
||||||
|
[self addSubview:item];
|
||||||
|
|
||||||
|
|
||||||
|
if (self.superview) {
|
||||||
|
|
||||||
|
[self removeConstraints:self.constraints];
|
||||||
|
for (TabBarItem *item in _tabBarItems) {
|
||||||
|
[item removeConstraints:item.constraints];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self layoutSubviews];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) layoutSubviewsPortrait {
|
- (void) layoutSubviewsPortrait {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
Pod/Classes/TabBarPickerSubItemsView.h
Normal file
14
Pod/Classes/TabBarPickerSubItemsView.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// TabBarPickerSubItemsView.h
|
||||||
|
// Pods
|
||||||
|
//
|
||||||
|
// Created by Giuseppe Nucifora on 17/07/15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@interface TabBarPickerSubItemsView : UIView
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
23
Pod/Classes/TabBarPickerSubItemsView.m
Normal file
23
Pod/Classes/TabBarPickerSubItemsView.m
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// TabBarPickerSubItemsView.m
|
||||||
|
// Pods
|
||||||
|
//
|
||||||
|
// Created by Giuseppe Nucifora on 17/07/15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TabBarPickerSubItemsView.h"
|
||||||
|
#import <PureLayout/PureLayout.h>
|
||||||
|
|
||||||
|
@implementation TabBarPickerSubItemsView
|
||||||
|
|
||||||
|
- (instancetype) init {
|
||||||
|
self = [self initForAutoLayout];
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
//#import "PureLayout.h"
|
|
||||||
|
|
||||||
@interface TabBarSubItem : UIView
|
@interface TabBarSubItem : UIView
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
//Obtain current device orientation
|
//Obtain current device orientation
|
||||||
_orientation = [[UIDevice currentDevice] orientation];
|
_orientation = [[UIDevice currentDevice] orientation];
|
||||||
|
|
||||||
|
[self layoutSubviews];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user