- Fix
This commit is contained in:
parent
603962375e
commit
61604557dd
4
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
4
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
@ -628,10 +628,10 @@
|
|||||||
4E0DA1B3F943CB5DD84434E2 /* Classes */ = {
|
4E0DA1B3F943CB5DD84434E2 /* Classes */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
948796D629A2FE463CD40F14 /* TabBarItem.h */,
|
|
||||||
6D0486D2A6CC5159ED6C3FA5 /* TabBarItem.m */,
|
|
||||||
6EBFE41004AD256533049528 /* TabBarPicker.h */,
|
6EBFE41004AD256533049528 /* TabBarPicker.h */,
|
||||||
66C7B75EB841D53F0EC483E0 /* TabBarPicker.m */,
|
66C7B75EB841D53F0EC483E0 /* TabBarPicker.m */,
|
||||||
|
948796D629A2FE463CD40F14 /* TabBarItem.h */,
|
||||||
|
6D0486D2A6CC5159ED6C3FA5 /* TabBarItem.m */,
|
||||||
038E63B1DBCA0584644ED157 /* TabBarPickerSubItemsView.h */,
|
038E63B1DBCA0584644ED157 /* TabBarPickerSubItemsView.h */,
|
||||||
13660ECE3ACE682AFF3887AC /* TabBarPickerSubItemsView.m */,
|
13660ECE3ACE682AFF3887AC /* TabBarPickerSubItemsView.m */,
|
||||||
489D9E1E1C7A2D5F8BC9F84C /* TabBarSubItem.h */,
|
489D9E1E1C7A2D5F8BC9F84C /* TabBarSubItem.h */,
|
||||||
|
|||||||
@ -58,11 +58,16 @@
|
|||||||
[allergen setImage:[UIImage imageNamed:@"allergen_off"]];
|
[allergen setImage:[UIImage imageNamed:@"allergen_off"]];
|
||||||
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
||||||
|
|
||||||
tabbar = [[TabBarPicker alloc] initWithTabBarItems:@[location,calendar,type,price,allergen] forPosition:TabBarPickerPositionBottom];
|
TabBarItem *allergen2 = [[TabBarItem alloc] initWithSubItems:@[subItem1,subItem2,subItem3,subItem4,subItem5,subItem6,subItem7]];
|
||||||
|
[allergen2 setItemName:@"Allergen"];
|
||||||
|
[allergen2 setImage:[UIImage imageNamed:@"allergen_off"]];
|
||||||
|
[allergen2 setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
||||||
|
|
||||||
|
tabbar = [[TabBarPicker alloc] initWithTabBarItems:@[location,calendar,type,price,allergen] forPosition:TabBarPickerPositionRight];
|
||||||
|
[tabbar setItemSpacing:2];
|
||||||
[tabbar setBackgroundColor:[UIColor whiteColor]];
|
[tabbar setBackgroundColor:[UIColor whiteColor]];
|
||||||
|
|
||||||
[tabbar addItem:allergen];
|
[tabbar addItem:allergen2];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -74,6 +79,8 @@
|
|||||||
[contentView addSubview:tabbar];
|
[contentView addSubview:tabbar];
|
||||||
|
|
||||||
self.view = contentView;
|
self.view = contentView;
|
||||||
|
|
||||||
|
[self.view setNeedsUpdateConstraints];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidLoad
|
- (void)viewDidLoad
|
||||||
@ -82,7 +89,6 @@
|
|||||||
|
|
||||||
//[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 {
|
- (void) viewDidAppear:(BOOL)animated {
|
||||||
@ -100,7 +106,9 @@
|
|||||||
[allergen setImage:[UIImage imageNamed:@"allergen_off"]];
|
[allergen setImage:[UIImage imageNamed:@"allergen_off"]];
|
||||||
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
[allergen setSelectedImage:[UIImage imageNamed:@"allergen_on"]];
|
||||||
|
|
||||||
[tabbar addItem:allergen];
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
[tabbar addItem:allergen];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
_orientation = [[UIDevice currentDevice] orientation];
|
_orientation = [[UIDevice currentDevice] orientation];
|
||||||
|
|
||||||
_itemButton = [[UIButton alloc] initForAutoLayout];
|
_itemButton = [[UIButton alloc] initForAutoLayout];
|
||||||
|
[_itemButton setBackgroundColor:[UIColor whiteColor]];
|
||||||
|
|
||||||
[self addSubview:_itemButton];
|
[self addSubview:_itemButton];
|
||||||
|
|
||||||
@ -44,7 +45,8 @@
|
|||||||
|
|
||||||
- (void) layoutSubviews {
|
- (void) layoutSubviews {
|
||||||
|
|
||||||
[_itemButton autoPinEdgesToSuperviewMargins];
|
//[_itemButton autoPinEdgesToSuperviewMargins];
|
||||||
|
[_itemButton autoCenterInSuperview];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,13 +60,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[self setNeedsUpdateConstraints];
|
[self updateConstraintsIfNeeded];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) layoutSubviews {
|
- (void) layoutSubviews {
|
||||||
|
|
||||||
|
if ([self.constraints count] > 0) {
|
||||||
|
|
||||||
|
[NSLayoutConstraint deactivateConstraints:self.constraints];
|
||||||
|
|
||||||
|
for (TabBarItem *item in _tabBarItems) {
|
||||||
|
[item.constraints autoRemoveConstraints];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (_position) {
|
switch (_position) {
|
||||||
case TabBarPickerPositionLeft:{
|
case TabBarPickerPositionLeft:{
|
||||||
[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:20];
|
[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:20];
|
||||||
@ -111,6 +120,7 @@
|
|||||||
break;
|
break;
|
||||||
case TabBarPickerPositionBottom:
|
case TabBarPickerPositionBottom:
|
||||||
default:{
|
default:{
|
||||||
|
|
||||||
[self autoPinEdgeToSuperviewMargin:ALEdgeBottom];
|
[self autoPinEdgeToSuperviewMargin:ALEdgeBottom];
|
||||||
[self autoSetDimension:ALDimensionHeight toSize:44];
|
[self autoSetDimension:ALDimensionHeight toSize:44];
|
||||||
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:_layoutRelation];
|
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:_layoutRelation];
|
||||||
@ -118,26 +128,20 @@
|
|||||||
|
|
||||||
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
|
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
|
||||||
|
|
||||||
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:0 insetSpacing:YES matchedSizes:YES];
|
|
||||||
|
|
||||||
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
|
||||||
|
|
||||||
|
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:_itemSpacing insetSpacing:YES matchedSizes:YES];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self updateConstraints];
|
[self updateConstraintsIfNeeded];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setPosition:(TabBarPickerPosition)position {
|
- (void) setPosition:(TabBarPickerPosition)position {
|
||||||
_position = position;
|
_position = position;
|
||||||
|
|
||||||
if (self.superview) {
|
if (self.superview) {
|
||||||
[self removeConstraints:self.constraints];
|
|
||||||
|
|
||||||
for (TabBarItem *item in _tabBarItems) {
|
|
||||||
[item removeConstraints:item.constraints];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self layoutSubviews];
|
[self layoutSubviews];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,15 +149,11 @@
|
|||||||
- (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) addItem:(TabBarItem*) item {
|
- (void) addItem:(TabBarItem*) item {
|
||||||
if (item && [item isKindOfClass:[TabBarItem class]]) {
|
if (item && [item isKindOfClass:[TabBarItem class]]) {
|
||||||
|
|
||||||
NSLog(@"%@",self.constraints);
|
|
||||||
|
|
||||||
[_tabBarItems addObject:item];
|
[_tabBarItems addObject:item];
|
||||||
[item setBackgroundColor:[UIColor lightGrayColor]];
|
[item setBackgroundColor:[UIColor lightGrayColor]];
|
||||||
[item setDelegate:self];
|
[item setDelegate:self];
|
||||||
@ -162,11 +162,6 @@
|
|||||||
|
|
||||||
if (self.superview) {
|
if (self.superview) {
|
||||||
|
|
||||||
[self removeConstraints:self.constraints];
|
|
||||||
for (TabBarItem *item in _tabBarItems) {
|
|
||||||
[item removeConstraints:item.constraints];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self layoutSubviews];
|
[self layoutSubviews];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user