- Fix Elements in ScrollView

This commit is contained in:
giuseppenuc committed 2015-08-07 14:34:01 +02:00
1 parent 4936fcd2ec
commit d4dbaff0e7
4 files changed
+27 -18

No files matched your search

@@ -95,6 +95,10 @@
- (void) viewDidAppear:(BOOL)animated {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[tabbar show];
});
/*TabBarSubItem *subItem1 = [TabBarSubItem tabBarSubItemWithName:@"Peppe"];
TabBarSubItem *subItem2 = [TabBarSubItem tabBarSubItemWithName:@"Peppe1"];
TabBarSubItem *subItem3 = [TabBarSubItem tabBarSubItemWithName:@"Peppe2"];
+19 -15
View File
@@ -27,7 +27,6 @@
@property (nonatomic, strong) NSLayoutConstraint *hideConstraint;
@property (nonatomic, strong) NSMutableArray *tabBarItemsConstraints;
@property (nonatomic, strong) TabBarItem *selectedTabBarItem;
@property (nonatomic, strong) MMCPSScrollView *subItemScrollView;
@end
@@ -98,6 +97,7 @@
[_subItemScrollView setType:MMCPSScrollHorizontal];
[_subItemScrollView setMMCPSDelegate:self];
[_subItemScrollView setPagingEnabled:YES];
[_subItemScrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[self addSubview:_subItemScrollView];
@@ -108,7 +108,7 @@
[subItemSelector setDelegate:self];
switch (i) {
case 0:
[subItemSelector setBackgroundColor:[UIColor lightGrayColor]];
break;
case 1:{
[subItemSelector setBackgroundColor:[UIColor redColor]];
@@ -119,16 +119,18 @@
}
break;
case 3: {
[subItemSelector setBackgroundColor:[UIColor yellowColor]];
}
break;
default:
break;
}
i++;
[_subItemScrollView addSubview:subItemSelector];
[_subItemSelectors addObject:subItemSelector];
}
[_subItemScrollView setPageSize:1];
}
}
@@ -138,15 +140,7 @@
}
- (void) layoutSubviews {
/*if ([self.constraints count] > 0) {
[NSLayoutConstraint deactivateConstraints:self.constraints];
[NSLayoutConstraint deactivateConstraints:_subItemSelector.constraints];
for (TabBarItem *item in _tabBarItems) {
[item.constraints autoRemoveConstraints];
}
}*/
if (!_didSetupConstraints) {
switch (_position) {
@@ -205,14 +199,23 @@
[_tabBarItemsConstraints addObjectsFromArray:[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:_itemSpacing insetSpacing:YES matchedSizes:YES]];
[_subItemSelectors autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:0 insetSpacing:YES matchedSizes:YES];
[_subItemScrollView autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
[_subItemScrollView autoSetDimension:ALDimensionHeight toSize:343];
[_subItemScrollView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:[_tabBarItems firstObject]];
[_subItemScrollView autoAlignAxisToSuperviewAxis:ALAxisVertical];
[_subItemScrollView setBackgroundColor:[UIColor blueColor]];
//[_subItemScrollView setPageSize:343];
[_subItemScrollView setSegmentSize:[[UIScreen mainScreen] bounds].size.width];
[_subItemSelectors autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:0 insetSpacing:YES matchedSizes:YES];
[_subItemSelectors autoSetViewsDimension:ALDimensionHeight toSize:343];
[_subItemSelectors autoSetViewsDimension:ALDimensionWidth toSize:[[UIScreen mainScreen] bounds].size.width];
[[_subItemSelectors firstObject] autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
[_subItemScrollView setContentSize:CGSizeMake([_subItemSelectors count]*[[UIScreen mainScreen] bounds].size.width , 343)];
}
break;
@@ -255,7 +258,6 @@
if (!_isShow) {
_isShow = YES;
[self setNeedsUpdateConstraints];
[self updateConstraintsIfNeeded];
@@ -377,6 +379,8 @@
}
}
_selectedTabBarItem = selectedItem;
[_subItemScrollView scrollToPage:[_tabBarItems indexOfObject:_selectedTabBarItem]];
}
#pragma mark -
+2 -3
View File
@@ -55,10 +55,9 @@
}*/
if (!_didSetupConstraints) {
[self autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:-(_rows*_itemHeight)];
//[self autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:-(_rows*_itemHeight)];
[self autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.superview withOffset:0 relation:NSLayoutRelationEqual];
[self autoSetDimension:ALDimensionHeight toSize:_rows*_itemHeight];
[self autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.superview withOffset:0 relation:NSLayoutRelationEqual];
_didSetupConstraints = YES;
}
}
+2
View File
@@ -51,4 +51,6 @@ typedef enum {
- (id)initWithFrame:(CGRect)frame andType:(MMCPSScrollType) type;
- (void) scrollToPage:(NSInteger) index;
@end