This commit is contained in:
giuseppenuc committed 2015-07-21 10:44:52 +02:00
1 parent 603962375e
commit 61604557dd
4 files changed
+31 -26

No files matched your search

+3 -1
View File
@@ -28,6 +28,7 @@
_orientation = [[UIDevice currentDevice] orientation];
_itemButton = [[UIButton alloc] initForAutoLayout];
[_itemButton setBackgroundColor:[UIColor whiteColor]];
[self addSubview:_itemButton];
@@ -44,7 +45,8 @@
- (void) layoutSubviews {
[_itemButton autoPinEdgesToSuperviewMargins];
//[_itemButton autoPinEdgesToSuperviewMargins];
[_itemButton autoCenterInSuperview];
}
+14 -19
View File
@@ -60,13 +60,22 @@
}
}
[self setNeedsUpdateConstraints];
[self updateConstraintsIfNeeded];
return self;
}
- (void) layoutSubviews {
if ([self.constraints count] > 0) {
[NSLayoutConstraint deactivateConstraints:self.constraints];
for (TabBarItem *item in _tabBarItems) {
[item.constraints autoRemoveConstraints];
}
}
switch (_position) {
case TabBarPickerPositionLeft:{
[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:20];
@@ -111,6 +120,7 @@
break;
case TabBarPickerPositionBottom:
default:{
[self autoPinEdgeToSuperviewMargin:ALEdgeBottom];
[self autoSetDimension:ALDimensionHeight toSize:44];
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:_layoutRelation];
@@ -118,26 +128,20 @@
[_tabBarItems autoSetViewsDimension:ALDimensionHeight toSize:44.0];
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:0 insetSpacing:YES matchedSizes:YES];
[[_tabBarItems firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:_itemSpacing insetSpacing:YES matchedSizes:YES];
}
break;
}
[self updateConstraints];
[self updateConstraintsIfNeeded];
}
- (void) setPosition:(TabBarPickerPosition)position {
_position = position;
if (self.superview) {
[self removeConstraints:self.constraints];
for (TabBarItem *item in _tabBarItems) {
[item removeConstraints:item.constraints];
}
[self layoutSubviews];
}
}
@@ -145,15 +149,11 @@
- (void)deviceOrientationDidChange:(NSNotification *)notification {
//Obtain current device orientation
_orientation = [[UIDevice currentDevice] orientation];
[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];
@@ -162,11 +162,6 @@
if (self.superview) {
[self removeConstraints:self.constraints];
for (TabBarItem *item in _tabBarItems) {
[item removeConstraints:item.constraints];
}
[self layoutSubviews];
}
}