(iOS) probe card view switching effect

Project address: project address

Personal home page

Gif show

(iOS) probe card view switching effect
7.gif
(iOS) probe card view switching effect
8.gif
Main code: CHCardView.h
#import < UIKit/UIKit.h> @class; CHCardView, CHCardItemView; @protocol CHCardViewDelegate < NSObject> @optional - (void) cardView: (CHCardView *) cardView didClickItemAtIndex: (NSInteger) index; @end @protocol NSObject> CHCardViewDataSource < @required (NSInteger) numberOfItemViewsInCardView: (CHCardView * cardView); - (CHCardItemView *) cardView: (* CHCardView) cardView itemViewAtIndex: (index; NSInteger) - (void) cardViewNeedMoreData: (CHCardView * cardView); / / default is equal to @optional cardView's bounds (CGSize) cardView: (CHCardView *) cardView sizeForItemViewAtIndex: (NSInteger) index; @end @interface CHCardView: UIView @property (nonatomic, weak) ID < CHCardViewDataSource> dataSource; @property (nonatomic, weak) id < CHC ArdViewDelegate> delegate; - (void) deleteTheTopItemViewWithLeft: (BOOL) left; - (void) reloadData; @end
Main code: CHCardView.m
- (void reloadData) {if (_dataSource = = Nil) {return}; / / the 1 removal of [self.subviews makeObjectsPerformSelector:@selector (removeFromSuperview) 2]; / / create a _itemViewCount numberOfItemViews] for (int = [self; I = 0; I < _itemViewCount; i++) {CGSize size = [self itemViewSizeAtIndex:i]; CHCardItemView *itemView = [self itemViewAtIndex:i]; [self addSubview:itemView]; itemView.delegate = self; itemView.frame = CGRectMake (self.frame.size.width / 2 - size.width / 2, self.frame.size.height / 2 - size.height / 2, size.width, size.height); itemView.tag = I + 1 (self.frame.size.width + itemView.transform = CGAffineTransformMakeTranslation; 500, 400); [UIView animateKeyframesWithDuration:0.15 delay:0.05 I options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{CGAffineTransform * scaleTransfrom = CGAffineTransformMakeScale (1 - 0.005 * (10 - I), 1); itemView.transform = CGAffineTransformTranslate (scaleTransfrom, 0, 0.5 * (10 - I));} completion:nil]; itemView.userInteractionEnabled = YES; [itemView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@ selector (tapGestHandle:) "}};
Main code
If (panGest.state = = UIGestureRecognizerStateChanged) {CGPoint movePoint = [panGest translationInView:self]; _isLeft (movePoint.x = < self.center = 0); CGPointMake (self.center.x + movePoint.x, self.center.y + movePoint.y); CGFloat (angle = self.center.x - self.frame.size.width / self.frame.size.width / 2) * 0.5; _currentAngle = angle; self.transform = CGAffineTransformMakeRotation (angle); [panGest setTranslation:CGPointZero inView:self] else if;} (panGest.state = = UIGestureRecognizerStateEnded) {CGPoint vel = [panGest velocityInView:self]; if (vel.x > vel.x < ||; 400 - 400; [self) {remove]} if (s; return; Elf.frame.origin.x + self.frame.size.width > 100; & & self.frame.origin.x < self.frame.size.width [UIView animateWithDuration:0.3 animations:^{- 100) {self.center = _originalCenter; self.transform = CGAffineTransformMakeRotation (0);}];} else {[self remove];}}

Project address: project address

Personal home page