https://github.com/keenteam1990/kttableviewroll
🍆KTTableviewRoll
https://github.com/keenteam1990/kttableviewroll
rolling
Last synced: 3 months ago
JSON representation
🍆KTTableviewRoll
- Host: GitHub
- URL: https://github.com/keenteam1990/kttableviewroll
- Owner: KeenTeam1990
- Created: 2018-05-02T14:13:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-02T14:21:37.000Z (about 8 years ago)
- Last Synced: 2024-12-31T03:23:25.444Z (over 1 year ago)
- Topics: rolling
- Language: Objective-C
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KTTableviewRoll
电商轮播标题广告(仿京东、淘宝)

实现方面,我利用UIView animateWithDuration结合CALayer的CATransform3D坐标变换做上下翻滚动画。
#pragma mark - 标题滚动
- (void)titleRolling{
if (self.saveMiddleArray.count > 1) { //所存的每组滚动
__weak typeof(self)weakSelf = self;
[UIView animateWithDuration:self.rollingTime animations:^{
[self getMiddleArrayWithIndex:0 WithAngle:- M_PI_2 Height:- RollingViewHeight / 2]; //第0组
[self getMiddleArrayWithIndex:1 WithAngle:0 Height:0]; //第一组
} completion:^(BOOL finished) {
if (finished == YES) { //旋转结束
UIButton *newMiddleView = [weakSelf getMiddleArrayWithIndex:0 WithAngle:M_PI_2 Height: -RollingViewHeight / 2];
[weakSelf.saveMiddleArray addObject:newMiddleView];
[weakSelf.saveMiddleArray removeObjectAtIndex:0];
}
}];
}
}
#pragma mark - CATransform3D翻转
- (UIButton *)getMiddleArrayWithIndex:(NSInteger)index WithAngle:(CGFloat)angle Height:(CGFloat)height
{
if (index > _saveMiddleArray.count) return 0;
UIButton *middleView = self.saveMiddleArray[index];
CATransform3D trans = CATransform3DIdentity;
trans = CATransform3DMakeRotation(angle, 1, 0, 0);
trans = CATransform3DTranslate(trans, 0, height, height);
middleView.layer.transform = trans;
return middleView;
}
如果这个Demo让你有所收获,请Star and Fork。
注:如果遇到问题还请Issues,我会尽快回复。