Comments (1)
Spend lots of time on it, and finally I write a custrom bahavior definer to do my job.
Some key notes are:
- make sure you set your scroll view's contentInset
- setup min height equals the pinned view height
Behaviour definer is just the same as the facebook style code. nothing more.
View controller demo code:
- (void)viewDidLoad {
[super viewDidLoad];
[self setNeedsStatusBarAppearanceUpdate];
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) collectionViewLayout:[[UICollectionViewFlowLayout alloc] init]];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
self.collectionView.dataSource = self;
[self.view addSubview:self.collectionView];
self.collectionView.backgroundColor = [UIColor blueColor];
BLKFlexibleHeightBar *myBar = [[BLKFlexibleHeightBar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 100)];
myBar.minimumBarHeight = 40;
myBar.backgroundColor = [UIColor redColor];
[self.view addSubview:myBar];
myBar.behaviorDefiner = [[MyBehaviorDefiner alloc] init];
UIView *menu = [[UIView alloc] init];
self.collectionView.delegate = myBar.behaviorDefiner;
self.collectionView.contentInset = UIEdgeInsetsMake(myBar.maximumBarHeight, 0, 0, 0); // must have
BLKFlexibleHeightBarSubviewLayoutAttributes *initialViewLayoutAttributes = [[BLKFlexibleHeightBarSubviewLayoutAttributes alloc] init];
initialViewLayoutAttributes.frame = CGRectMake(0,60,self.view.bounds.size.width,40);
[menu addLayoutAttributes:initialViewLayoutAttributes forProgress:0];
BLKFlexibleHeightBarSubviewLayoutAttributes *finalViewLayoutAttributes = [[BLKFlexibleHeightBarSubviewLayoutAttributes alloc] initWithExistingLayoutAttributes:initialViewLayoutAttributes];
finalViewLayoutAttributes.transform = CGAffineTransformMakeTranslation(0, -40);
[menu addLayoutAttributes:finalViewLayoutAttributes forProgress:1.0];
menu.backgroundColor = [UIColor yellowColor];
[myBar addSubview:menu];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 20;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor greenColor];
return cell;
}
from blkflexibleheightbar.
Related Issues (20)
- support AutoLayout HOT 1
- ScrollView setContentOffset not working after setup BLKFlexibleHeightBar. HOT 1
- Fast swiping down cause flexibleHeader not take effect immediately
- Problems synchronising the bar with table view scrolling.
- does not work with swift ? HOT 3
- Broken indicator insets HOT 1
- problem with elasticMaximumHeightAtTop when I need a negative progress
- Something wrong with BLKFlexibleHeightBar when I put scrollView into it HOT 2
- Why use delegate rather than KVO contentOffset/contentSize?
- Usage inside NavigationViewController
- FacebookStyleBarBehaviorDefiner with pagination
- Carthage support
- issue with add subview my custom UIView can any one help me on this
- When I use BLKFlexibleHeightBar in a UIWebview, the webview can't display properly.
- Use library in tabbar?
- Bar overlaps with native status-bar on iPhone X
- How to change actual height (frame.height) of BLKFlexibleHeightBar?
- BLKFlexibleHeightBar
- Cash App
- CASH APP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blkflexibleheightbar.