ios中圆形轮子动画的实现
我必须做一个动画,比如: 目前,我正在尝试使用自定义集合视图布局和UICollectionViewLayout子类化来实现这一点 有什么帮助或方法可以做到这一点吗?ios中圆形轮子动画的实现,ios,objective-c,animation,uicollectionview,uicollectionviewlayout,Ios,Objective C,Animation,Uicollectionview,Uicollectionviewlayout,我必须做一个动画,比如: 目前,我正在尝试使用自定义集合视图布局和UICollectionViewLayout子类化来实现这一点 有什么帮助或方法可以做到这一点吗? 我有同样的任务,这就是我发现的: 您可以根据Rounak Jain编写的精彩教程制作自己的解决方案。本教程可在以下位置获得: 您可以重用现有代码 由于时间限制,我选择了第二种变体,我发现最好的回购协议是: 使用方法非常简单,但有两个技巧非常有用: scrollToItemAtIndexPath不工作,正在使应用程序崩溃。
我有同样的任务,这就是我发现的:
由于时间限制,我选择了第二种变体,我发现最好的回购协议是:
使用方法非常简单,但有两个技巧非常有用:
#导入“arnRouletteWheelledCellScaledAndRotated.h”
#进口
@实现arnRouletteWheelledCellScaledAndRotated
-(void)applyLayoutAttributes:(UICollectionViewLayoutAttribute*)LayoutAttribute{
[超级applyLayoutAttributes:LayoutAttribute];
if(layouttributes!=nil&[layouttributes是类:[arnRouletteWheelLayouttributes类]]{
arnRouletteWheelLayoutAttribute*RouletteWheelLayoutAttribute=(arnRouletteWheelLayoutAttribute*)LayoutAttribute;
self.layer.anchorPoint=RouletteWheelLayoutAttribute.anchorPoint;
//更新Y中心以反映定位点
CGPoint center=CGPointMake(self.center.x,self.center.y+((roulettewheelllayouttributes.anchorPoint.y-0.5)*CGRectGetHeight(self.bounds));
自我中心=中心;
//回转
CGAffineTransform rotate=CGAffineTransformMakeRotation(-RouletteWheelLayoutAttribute.angle);
//鳞片
CGFloat scale=1-fabs(轮盘赌轮布局属性角度);
CGAffineTransform translate=CGAffineTransformMakeScale(缩放,缩放);
//将它们应用于视图
self.imageView.transform=CGAffineTransformConcat(平移、旋转);
}
}
@结束
使用并自定义它。我尝试过使用这个旋转木马,但这并不能解决我的问题。
#import "ARNRouletteWheelCellScaledAndRotated.h"
#import <ARNRouletteWheelView/ARNRouletteWheelLayoutAttributes.h>
@implementation ARNRouletteWheelCellScaledAndRotated
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
[super applyLayoutAttributes:layoutAttributes];
if(layoutAttributes != nil && [layoutAttributes isKindOfClass:[ARNRouletteWheelLayoutAttributes class]]) {
ARNRouletteWheelLayoutAttributes *rouletteWheelLayoutAttributes = (ARNRouletteWheelLayoutAttributes *)layoutAttributes;
self.layer.anchorPoint = rouletteWheelLayoutAttributes.anchorPoint;
// update the Y center to reflect the anchor point
CGPoint center = CGPointMake(self.center.x, self.center.y + ((rouletteWheelLayoutAttributes.anchorPoint.y - 0.5) * CGRectGetHeight(self.bounds)));
self.center = center;
// rotate back
CGAffineTransform rotate = CGAffineTransformMakeRotation(-rouletteWheelLayoutAttributes.angle);
// scale
CGFloat scale = 1 - fabs(rouletteWheelLayoutAttributes.angle);
CGAffineTransform translate = CGAffineTransformMakeScale(scale, scale);
// Apply them to a view
self.imageView.transform = CGAffineTransformConcat(translate, rotate);
}
}
@end