要实现UICollectionView在添加或删除一项是放大缩小动画。
- 自定义UICollectionViewFlowLayout
创建子类MyChosenFlowLayout 继承自 UICollectionViewFlowLayout
#import <UIKit/UIKit.h>
@interface MyChosenFlowLayout : UICollectionViewFlowLayout
@property (nonatomic, assign) NSInteger addAnimatedIndex;
@property (nonatomic, assign) NSInteger removeAnimatedIndex;
@end
#import "MyProductChosenFlowLayout.h"
@implementation MyChosenFlowLayout
// 添加时动画
- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath {
UICollectionViewLayoutAttributes *attributes = [super initialLayoutAttributesForAppearingItemAtIndexPath:itemIndexPath];
if (self.addAnimatedIndex == itemIndexPath.row) {
attributes.transform =