- Fix Elements in ScrollView
This commit is contained in:
parent
4936fcd2ec
commit
d4dbaff0e7
@ -95,6 +95,10 @@
|
|||||||
|
|
||||||
- (void) viewDidAppear:(BOOL)animated {
|
- (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 *subItem1 = [TabBarSubItem tabBarSubItemWithName:@"Peppe"];
|
||||||
TabBarSubItem *subItem2 = [TabBarSubItem tabBarSubItemWithName:@"Peppe1"];
|
TabBarSubItem *subItem2 = [TabBarSubItem tabBarSubItemWithName:@"Peppe1"];
|
||||||
TabBarSubItem *subItem3 = [TabBarSubItem tabBarSubItemWithName:@"Peppe2"];
|
TabBarSubItem *subItem3 = [TabBarSubItem tabBarSubItemWithName:@"Peppe2"];
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
@property (nonatomic, strong) NSLayoutConstraint *hideConstraint;
|
@property (nonatomic, strong) NSLayoutConstraint *hideConstraint;
|
||||||
@property (nonatomic, strong) NSMutableArray *tabBarItemsConstraints;
|
@property (nonatomic, strong) NSMutableArray *tabBarItemsConstraints;
|
||||||
@property (nonatomic, strong) TabBarItem *selectedTabBarItem;
|
@property (nonatomic, strong) TabBarItem *selectedTabBarItem;
|
||||||
|
|
||||||
@property (nonatomic, strong) MMCPSScrollView *subItemScrollView;
|
@property (nonatomic, strong) MMCPSScrollView *subItemScrollView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@ -98,6 +97,7 @@
|
|||||||
[_subItemScrollView setType:MMCPSScrollHorizontal];
|
[_subItemScrollView setType:MMCPSScrollHorizontal];
|
||||||
[_subItemScrollView setMMCPSDelegate:self];
|
[_subItemScrollView setMMCPSDelegate:self];
|
||||||
[_subItemScrollView setPagingEnabled:YES];
|
[_subItemScrollView setPagingEnabled:YES];
|
||||||
|
[_subItemScrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
|
||||||
|
|
||||||
[self addSubview:_subItemScrollView];
|
[self addSubview:_subItemScrollView];
|
||||||
|
|
||||||
@ -108,7 +108,7 @@
|
|||||||
[subItemSelector setDelegate:self];
|
[subItemSelector setDelegate:self];
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
|
[subItemSelector setBackgroundColor:[UIColor lightGrayColor]];
|
||||||
break;
|
break;
|
||||||
case 1:{
|
case 1:{
|
||||||
[subItemSelector setBackgroundColor:[UIColor redColor]];
|
[subItemSelector setBackgroundColor:[UIColor redColor]];
|
||||||
@ -119,16 +119,18 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: {
|
case 3: {
|
||||||
|
[subItemSelector setBackgroundColor:[UIColor yellowColor]];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
[_subItemScrollView addSubview:subItemSelector];
|
[_subItemScrollView addSubview:subItemSelector];
|
||||||
|
|
||||||
[_subItemSelectors addObject:subItemSelector];
|
[_subItemSelectors addObject:subItemSelector];
|
||||||
}
|
}
|
||||||
|
[_subItemScrollView setPageSize:1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,14 +141,6 @@
|
|||||||
|
|
||||||
- (void) layoutSubviews {
|
- (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) {
|
if (!_didSetupConstraints) {
|
||||||
|
|
||||||
switch (_position) {
|
switch (_position) {
|
||||||
@ -205,14 +199,23 @@
|
|||||||
|
|
||||||
[_tabBarItemsConstraints addObjectsFromArray:[_tabBarItems autoDistributeViewsAlongAxis:ALAxisHorizontal alignedTo:ALAttributeHorizontal withFixedSpacing:_itemSpacing insetSpacing:YES matchedSizes:YES]];
|
[_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 autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self];
|
||||||
[_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 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;
|
break;
|
||||||
@ -255,7 +258,6 @@
|
|||||||
|
|
||||||
if (!_isShow) {
|
if (!_isShow) {
|
||||||
|
|
||||||
|
|
||||||
_isShow = YES;
|
_isShow = YES;
|
||||||
[self setNeedsUpdateConstraints];
|
[self setNeedsUpdateConstraints];
|
||||||
[self updateConstraintsIfNeeded];
|
[self updateConstraintsIfNeeded];
|
||||||
@ -377,6 +379,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_selectedTabBarItem = selectedItem;
|
_selectedTabBarItem = selectedItem;
|
||||||
|
|
||||||
|
[_subItemScrollView scrollToPage:[_tabBarItems indexOfObject:_selectedTabBarItem]];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|||||||
@ -55,10 +55,9 @@
|
|||||||
}*/
|
}*/
|
||||||
if (!_didSetupConstraints) {
|
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 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;
|
_didSetupConstraints = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,4 +51,6 @@ typedef enum {
|
|||||||
|
|
||||||
- (id)initWithFrame:(CGRect)frame andType:(MMCPSScrollType) type;
|
- (id)initWithFrame:(CGRect)frame andType:(MMCPSScrollType) type;
|
||||||
|
|
||||||
|
- (void) scrollToPage:(NSInteger) index;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user