项目
在 GitHub 查看
jberlana/JBParallaxCell
关于
该项目在表格滚动时,为 `UITAbleViewCell` 中的 `UIImageView` 添加视差效果。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文iOS Parallax effect on images of UITableViewCell
The goal of this project is to create a parallax effect on a UIImageView on a UITableViewCell when the table scrolls.
This code has been created originally to provide a parallax effect on meets's discover tab.

Download the app and test it for free! Feedback is welcome!
Documentation
On your UITableViewCell
- Put the
parallaxImageViewinside aUIViewwithclipsToBounds = YES;with some offest. - Add this function to calculate the image offset when the
UITableViewscrolls.
- (void)cellOnTableView:(UITableView *)tableView didScrollOnView:(UIView *)view
{
CGRect rectInSuperview = [tableView convertRect:self.frame toView:view];
float distanceFromCenter = CGRectGetHeight(view.frame)/2 - CGRectGetMinY(rectInSuperview);
float difference = CGRectGetHeight(self.parallaxImage.frame) - CGRectGetHeight(self.frame);
float move = (distanceFromCenter / CGRectGetHeight(view.frame)) * difference;
CGRect imageRect = self.parallaxImage.frame;
imageRect.origin.y = -(difference/2)+move;
self.parallaxImage.frame = imageRect;
}
On your UITableViewDelegate add this function.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// Get visible cells on table view.
NSArray *visibleCells = [self.tableView visibleCells];
for (JBParallaxCell *cell in visibleCells) {
[cell cellOnTableView:self.tableView didScrollOnView:self.view];
}
}
And that is all, you can use the demo project to see how everithig works together.
-- ###meets, create and discover plans with your friends.###
探索相关项目
加载中…