https://github.com/keenteam1990/kttitlerolling
🇨🇳电商滚动广告标题
https://github.com/keenteam1990/kttitlerolling
objective-c roll
Last synced: 4 months ago
JSON representation
🇨🇳电商滚动广告标题
- Host: GitHub
- URL: https://github.com/keenteam1990/kttitlerolling
- Owner: KeenTeam1990
- License: apache-2.0
- Created: 2017-11-30T03:24:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-30T03:39:59.000Z (over 7 years ago)
- Last Synced: 2024-12-31T03:23:24.658Z (6 months ago)
- Topics: objective-c, roll
- Language: Objective-C
- Homepage:
- Size: 2.28 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CDDTitleRolling
电商轮播标题广告(仿京东、淘宝)

实现方面,我利用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,我会尽快回复。