text
stringlengths
9
39.2M
dir
stringlengths
26
295
lang
stringclasses
185 values
created_date
timestamp[us]
updated_date
timestamp[us]
repo_name
stringlengths
1
97
repo_full_name
stringlengths
7
106
star
int64
1k
183k
len_tokens
int64
1
13.8M
```objective-c // // YFITRAirSideViewController.h // BigShow1949 // // Created by zhht01 on 16/5/11. // #import <UIKit/UIKit.h> #import "ITRAirSideMenu.h" @interface YFITRAirSideViewController : UIViewController @property ITRAirSideMenu *itrAirSideMenu; @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/ITRAirSideMenu/YFITRAirSideViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
75
```objective-c // // YFITRAirSideViewController.m // BigShow1949 // // Created by zhht01 on 16/5/11. // #import "YFITRAirSideViewController.h" #import "ITRFirstViewController.h" #import "ITRLeftMenuController.h" @implementation YFITRAirSideViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; btn.backgroundColor = [UIColor redColor]; [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside]; [btn setTitle:@"" forState:UIControlStateNormal]; [self.view addSubview:btn]; } - (void)btnClick { //sidemenu created with content view controller & menu view controller UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:[ITRFirstViewController controller]]; ITRLeftMenuController *leftMenuViewController = [ITRLeftMenuController controller]; _itrAirSideMenu = [[ITRAirSideMenu alloc] initWithContentViewController:navigationController leftMenuViewController:leftMenuViewController]; _itrAirSideMenu.backgroundImage = [UIImage imageNamed:@"menu_bg.jpg"]; //optional delegate to receive menu view status _itrAirSideMenu.delegate = leftMenuViewController; //content view shadow properties _itrAirSideMenu.contentViewShadowColor = [UIColor blackColor]; _itrAirSideMenu.contentViewShadowOffset = CGSizeMake(0, 0); _itrAirSideMenu.contentViewShadowOpacity = 0.6; _itrAirSideMenu.contentViewShadowRadius = 12; _itrAirSideMenu.contentViewShadowEnabled = YES; //content view animation properties _itrAirSideMenu.contentViewScaleValue = 0.7f; _itrAirSideMenu.contentViewRotatingAngle = 30.0f; _itrAirSideMenu.contentViewTranslateX = 130.0f; //menu view properties _itrAirSideMenu.menuViewRotatingAngle = 30.0f; _itrAirSideMenu.menuViewTranslateX = 130.0f; [self presentViewController:_itrAirSideMenu animated:NO completion:nil]; } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/ITRAirSideMenu/YFITRAirSideViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
481
```objective-c // // ViewController.m // ITRAirSideMenu // // Created by kirthi on 11/08/15. // #import "ITRFirstViewController.h" #import "ITRAirSideMenu.h" #import "AppDelegate.h" @interface ITRFirstViewController () @end @implementation ITRFirstViewController + (instancetype) controller{ // UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; // return [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([ITRFirstViewController class])]; ITRFirstViewController *firstVC = [[ITRFirstViewController alloc] init]; firstVC.view.backgroundColor = [UIColor lightGrayColor]; return firstVC; } #pragma view lifecycle - (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBar.translucent = NO; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStylePlain target:self action:@selector(presentLeftMenuViewController)]; } - (void) presentLeftMenuViewController{ //show left menu with animation // ITRAirSideMenu *itrSideMenu = ((AppDelegate *)[UIApplication sharedApplication].delegate).itrAirSideMenu; // [itrSideMenu presentLeftMenuViewController]; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/ITRAirSideMenu/ITRFirstViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
288
```objective-c // // YFFlipPageViewController.h // BigShow1949 // // Created by zhht01 on 16/3/17. // #import <UIKit/UIKit.h> @interface YFFlipPageViewController : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/YFFlipPageViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
52
```objective-c // // YFFlipPageViewController.m // BigShow1949 // // Created by zhht01 on 16/3/17. // #import "YFFlipPageViewController.h" #import "JCFlipPageView.h" #import "JCFlipPage.h" @interface YFFlipPageViewController ()<JCFlipPageViewDataSource> @property (nonatomic, strong) JCFlipPageView *flipPage; @end @implementation YFFlipPageViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _flipPage = [[JCFlipPageView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:_flipPage]; _flipPage.dataSource = self; [_flipPage reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mar - JCFlipPageViewDataSource - (NSUInteger)numberOfPagesInFlipPageView:(JCFlipPageView *)flipPageView { return 20; } - (JCFlipPage *)flipPageView:(JCFlipPageView *)flipPageView pageAtIndex:(NSUInteger)index { static NSString *kPageID = @"numberPageID"; JCFlipPage *page = [flipPageView dequeueReusablePageWithReuseIdentifier:kPageID]; if (!page) { page = [[JCFlipPage alloc] initWithFrame:flipPageView.bounds reuseIdentifier:kPageID]; }else{} if (index%3 == 0) { page.backgroundColor = [UIColor blueColor]; } else if (index%3 == 1) { page.backgroundColor = [UIColor greenColor]; } else if (index%3 == 2) { page.backgroundColor = [UIColor redColor]; }else{} page.tempContentLabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)index]; return page; } #pragma mark - - (void)showPage:(NSNumber *)pageNum { [_flipPage flipToPageAtIndex:pageNum.integerValue animation:YES]; } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/YFFlipPageViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
447
```objective-c // // JCFlipPage.m // JCFlipPageView // // Created by ThreegeneDev on 14-8-8. // #import "JCFlipPage.h" @implementation JCFlipPage @synthesize reuseIdentifier = _reuseIdentifier; - (void)dealloc { } - (void)prepareForReuse { } - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithFrame:frame]; if (self) { // Initialization code _reuseIdentifier = reuseIdentifier; #warning ! a temp label _tempContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 300.0f, 300.0f)]; _tempContentLabel.numberOfLines = 1; _tempContentLabel.text = @""; _tempContentLabel.font = [UIFont systemFontOfSize:200.0f]; _tempContentLabel.textAlignment = NSTextAlignmentCenter; _tempContentLabel.center = CGPointMake(self.bounds.size.width/2.0f, self.bounds.size.height/2.0f); [self addSubview:_tempContentLabel]; self.backgroundColor = [UIColor lightGrayColor]; _tempContentLabel.backgroundColor = [UIColor clearColor]; } return self; } - (void)setReuseIdentifier:(NSString *)identifier { _reuseIdentifier = identifier; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/JCFlipPage.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
328
```objective-c // // JCFlipPage.h // JCFlipPageView // // Created by ThreegeneDev on 14-8-8. // #import <UIKit/UIKit.h> static NSString const* kJCFlipPageDefaultReusableIdentifier = @"kJCFlipPageDefaultReusableIdentifier"; @interface JCFlipPage : UIView @property (nonatomic, readonly, copy) NSString *reuseIdentifier; @property (nonatomic, strong) UILabel *tempContentLabel; - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier; - (void)prepareForReuse; - (void)setReuseIdentifier:(NSString *)identifier; @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/JCFlipPage.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
125
```objective-c #import "ITRAirSideMenu.h" @interface ITRAirSideMenu () @property (assign, readwrite, nonatomic) CGFloat totalAngle; @property (assign, readwrite, nonatomic) CGPoint lastPoint; @property (strong, readwrite, nonatomic) UIImageView *backgroundImageView; @property (assign, readwrite, nonatomic) BOOL visible; @property (assign, readwrite, nonatomic) BOOL isLeftMenuVisible; @property (strong, readwrite, nonatomic) UIButton *contentButton; @property (strong, readwrite, nonatomic) UIView *menuViewContainer; @property (strong, readwrite, nonatomic) UIView *contentViewContainer; @property (assign, readwrite, nonatomic) BOOL didNotifyDelegate; @end @implementation ITRAirSideMenu #pragma mark - #pragma mark Instance lifecycle - (id)init { self = [super init]; if (self) { [self commonInit]; } return self; } - (id)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (self) { [self commonInit]; } return self; } //initial setup - (void)commonInit { _menuViewContainer = [[UIView alloc] init]; _contentViewContainer = [[UIView alloc] init]; _animationDuration = 0.35f; _interactivePopGestureRecognizerEnabled = YES; _panGestureEnabled = YES; _panFromEdge = YES; _panMinimumOpenThreshold = 60.0; _contentViewShadowEnabled = NO; _contentViewShadowColor = [UIColor blackColor]; _contentViewShadowOffset = CGSizeZero; _contentViewShadowOpacity = 0.4f; _contentViewShadowRadius = 8.0f; _contentViewFadeOutAlpha = 1.0f; _contentViewScaleValue = 0.7f; _contentViewRotatingAngle = 30.0f; _contentViewTranslateX = 150.0f; _menuViewRotatingAngle = 30.0f; _menuViewTranslateX = 150.0f; } #pragma mark - #pragma mark Public methods - (id)initWithContentViewController:(UIViewController *)contentViewController leftMenuViewController:(UIViewController *)leftMenuViewController { self = [self init]; if (self) { _contentViewController = contentViewController; _leftMenuViewController = leftMenuViewController; } return self; } - (void)presentLeftMenuViewController { [self presentMenuViewContainerWithMenuViewController:self.leftMenuViewController]; [self showLeftMenuViewController]; } - (void)hideMenuViewController { [self hideMenuViewControllerAnimated:YES]; } - (void)setContentViewController:(UIViewController *)contentViewController animated:(BOOL)animated { if (_contentViewController == contentViewController) { return; } //contentview controller updated if (!animated) { [self setContentViewController:contentViewController]; } else { [self addChildViewController:contentViewController]; contentViewController.view.alpha = 0; contentViewController.view.frame = self.contentViewContainer.bounds; contentViewController.view.layer.transform = self.contentViewController.view.layer.transform; contentViewController.view.superview.layer.sublayerTransform = _contentViewController.view.superview.layer.sublayerTransform; [self.contentViewContainer addSubview:contentViewController.view]; [UIView animateWithDuration:self.animationDuration animations:^{ contentViewController.view.alpha = 1; } completion:^(BOOL finished) { [self hideViewController:self.contentViewController]; [contentViewController didMoveToParentViewController:self]; _contentViewController = contentViewController; [self updateContentViewShadow]; }]; } } #pragma mark View life cycle - (void)viewDidLoad { [super viewDidLoad]; self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.backgroundImageView = ({ UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; imageView.image = self.backgroundImage; imageView.contentMode = UIViewContentModeScaleAspectFill; imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; imageView; }); self.contentButton = ({ UIButton *button = [[UIButton alloc] initWithFrame:CGRectNull]; [button addTarget:self action:@selector(hideMenuViewController) forControlEvents:UIControlEventTouchUpInside]; button; }); [self.view addSubview:self.backgroundImageView]; [self.view addSubview:self.menuViewContainer]; [self.view addSubview:self.contentViewContainer]; [self.view bringSubviewToFront:self.contentViewContainer]; self.menuViewContainer.frame = self.view.bounds; self.menuViewContainer.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; if (self.leftMenuViewController) { [self addChildViewController:self.leftMenuViewController]; self.leftMenuViewController.view.frame = self.view.bounds; self.leftMenuViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self.menuViewContainer addSubview:self.leftMenuViewController.view]; [self.leftMenuViewController didMoveToParentViewController:self]; } self.contentViewContainer.frame = self.view.bounds; self.contentViewContainer.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self addChildViewController:self.contentViewController]; self.contentViewController.view.frame = self.view.bounds; [self.contentViewContainer addSubview:self.contentViewController.view]; [self.contentViewController didMoveToParentViewController:self]; if (self.panGestureEnabled) { self.view.multipleTouchEnabled = NO; UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognized:)]; panGestureRecognizer.delegate = self; [_contentViewContainer addGestureRecognizer:panGestureRecognizer]; } [_contentViewContainer setBackgroundColor:[UIColor clearColor]]; [self updateContentViewShadow]; } #pragma mark - #pragma mark Private methods - (void)presentMenuViewContainerWithMenuViewController:(UIViewController *)menuViewController { [self setAnchorPoint:CGPointMake(0.0, 0.5) forView:_menuViewContainer]; self.menuViewContainer.transform = CGAffineTransformIdentity; self.menuViewContainer.frame = self.view.bounds; if (_menuViewRotatingAngle != 0) { //menu view rotation transform CATransform3D menuRotationTransform = _leftMenuViewController.view.layer.transform; menuRotationTransform = CATransform3DMakeRotation(_menuViewRotatingAngle * M_PI/180.0f, 0.0f, -1.0f, 0.0f); CATransform3D sublayerTransform = _leftMenuViewController.view.superview.layer.sublayerTransform; sublayerTransform.m34 = 1.0f / -300.0f; _leftMenuViewController.view.superview.layer.sublayerTransform = sublayerTransform; _leftMenuViewController.view.layer.transform = menuRotationTransform; } //rotation view translate transform CATransform3D menuTranslateTransform = _menuViewContainer.layer.transform; menuTranslateTransform = CATransform3DTranslate(menuTranslateTransform, -_menuViewTranslateX, 0, 0); _menuViewContainer.layer.transform = menuTranslateTransform; } - (void)showLeftMenuViewController { if (!self.leftMenuViewController) { return; } if (!self.visible && [self.delegate conformsToProtocol:@protocol(ITRAirSideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:willShowMenuViewController:)]) { [self.delegate sideMenu:self willShowMenuViewController:_leftMenuViewController]; } [self.leftMenuViewController beginAppearanceTransition:YES animated:YES]; self.leftMenuViewController.view.hidden = NO; [self.view.window endEditing:YES]; [self addContentButton]; [self updateContentViewShadow]; //anchor point set to change the origin of rotation. value ranges from 0 to 1.0 (0 to width/height) [self setAnchorPoint:CGPointMake(0.0, 0.5) forView:_menuViewContainer]; [self setAnchorPoint:CGPointMake(1.0, 0.5) forView:_contentViewContainer]; [self setAnchorPoint:CGPointMake(1.0, 0.5) forView:_contentViewController.view]; [UIView animateWithDuration:self.animationDuration animations:^{ //content view scale transform CATransform3D contentScaleTransform = _contentViewContainer.layer.transform; contentScaleTransform = CATransform3DMakeScale(_contentViewScaleValue, _contentViewScaleValue,1.0f); _contentViewContainer.layer.transform = contentScaleTransform; if (_contentViewRotatingAngle != 0) { //content view rotate transform CATransform3D contentRotateTransform = _contentViewController.view.layer.transform; contentRotateTransform = CATransform3DMakeRotation(_contentViewRotatingAngle * M_PI/180.0f, 0.0f, -1.0f, 0.0f); CATransform3D sublayerTransform = _contentViewController.view.superview.layer.sublayerTransform; sublayerTransform.m34 = 1.0f / -300.0f; _contentViewController.view.superview.layer.sublayerTransform = sublayerTransform; _contentViewController.view.layer.transform = contentRotateTransform; } //content view translate transform CATransform3D contentTranslateTransform = _contentViewContainer.layer.transform; contentTranslateTransform = CATransform3DTranslate(contentTranslateTransform, _contentViewTranslateX, 0, 0); _contentViewContainer.layer.transform = contentTranslateTransform; if (_menuViewRotatingAngle != 0) { //menu view rotate transform CATransform3D menuRotateTransform = _leftMenuViewController.view.layer.transform; menuRotateTransform = CATransform3DMakeRotation(0 * M_PI/180.0f, 0.0f, -1.0f, 0.0f); CATransform3D sublayerTransform1 = _leftMenuViewController.view.superview.layer.sublayerTransform; sublayerTransform1.m34 = 1.0f / -300.0f; _leftMenuViewController.view.superview.layer.sublayerTransform = sublayerTransform1; _leftMenuViewController.view.layer.transform = menuRotateTransform; } _menuViewContainer.layer.transform = CATransform3DIdentity; } completion:^(BOOL finished) { self.isLeftMenuVisible = YES; if (!self.visible && [self.delegate conformsToProtocol:@protocol(ITRAirSideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:didShowMenuViewController:)]) { [self.delegate sideMenu:self didShowMenuViewController:_leftMenuViewController]; } self.visible = YES; }]; } - (void)hideViewController:(UIViewController *)viewController { [viewController willMoveToParentViewController:nil]; [viewController.view removeFromSuperview]; [viewController removeFromParentViewController]; } //hide left menu view controller - (void)hideMenuViewControllerAnimated:(BOOL)animated { UIViewController *visibleMenuViewController = self.leftMenuViewController; [visibleMenuViewController beginAppearanceTransition:NO animated:animated]; if (self.visible && [self.delegate conformsToProtocol:@protocol(ITRAirSideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:willHideMenuViewController:)]) { [self.delegate sideMenu:self willHideMenuViewController:self.leftMenuViewController]; } __typeof (self) __weak weakSelf = self; void (^animationBlock)(void) = ^{ __typeof (weakSelf) __strong strongSelf = weakSelf; if (!strongSelf) { return; } //content view scale transform CATransform3D contentScaleTransform = _contentViewContainer.layer.transform; contentScaleTransform = CATransform3DMakeScale(1.0, 1.0,1.0f); _contentViewContainer.layer.transform = contentScaleTransform; if (_contentViewRotatingAngle != 0) { //content view rotate transform CATransform3D contentRotateTransform = _contentViewController.view.layer.transform; contentRotateTransform = CATransform3DMakeRotation(0 * M_PI/180.0f, 0.0f, 1.0f, 0.0f); CATransform3D sublayerTransform = _contentViewController.view.superview.layer.sublayerTransform; sublayerTransform.m34 = 1.0f / -300.0f; _contentViewController.view.superview.layer.sublayerTransform = sublayerTransform; _contentViewController.view.layer.transform = contentRotateTransform; } //content view translate transform CATransform3D contentTranslateTransform = _contentViewContainer.layer.transform; contentTranslateTransform = CATransform3DTranslate(contentTranslateTransform, 0, 0, 0); _contentViewContainer.layer.transform = contentTranslateTransform; if (_menuViewRotatingAngle != 0) { //menu view rotate transform CATransform3D menuRotateTransform = _leftMenuViewController.view.layer.transform; menuRotateTransform = CATransform3DMakeRotation(_menuViewRotatingAngle * M_PI/180.0f, 0.0f, -1.0f, 0.0f); CATransform3D sublayerTransform1 = _leftMenuViewController.view.superview.layer.sublayerTransform; sublayerTransform1.m34 = 1.0f / -300.0f; _leftMenuViewController.view.superview.layer.sublayerTransform = sublayerTransform1; _leftMenuViewController.view.layer.transform = menuRotateTransform; } //menu view translate transform CATransform3D menuTranslateTransform = CATransform3DIdentity; menuTranslateTransform = CATransform3DTranslate(menuTranslateTransform, -_menuViewTranslateX, 0, 0); _menuViewContainer.layer.transform = menuTranslateTransform; }; void (^completionBlock)(void) = ^{ __typeof (weakSelf) __strong strongSelf = weakSelf; if (!strongSelf) { return; } [visibleMenuViewController endAppearanceTransition]; [self.contentButton removeFromSuperview]; strongSelf.isLeftMenuVisible = NO; if (strongSelf.visible && [strongSelf.delegate conformsToProtocol:@protocol(ITRAirSideMenuDelegate)] && [strongSelf.delegate respondsToSelector:@selector(sideMenu:didHideMenuViewController:)]) { [strongSelf.delegate sideMenu:strongSelf didHideMenuViewController:strongSelf.leftMenuViewController]; } strongSelf.visible = NO; }; if (animated) { [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; [UIView animateWithDuration:self.animationDuration animations:^{ animationBlock(); } completion:^(BOOL finished) { [[UIApplication sharedApplication] endIgnoringInteractionEvents]; completionBlock(); }]; } else { animationBlock(); completionBlock(); } } //content button added as subview when left menu is shown - (void)addContentButton { if (self.contentButton.superview) return; self.contentButton.autoresizingMask = UIViewAutoresizingNone; self.contentButton.frame = self.contentViewContainer.bounds; self.contentButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self.contentViewController.view addSubview:self.contentButton]; } //update shadow to content view - (void)updateContentViewShadow { if (self.contentViewShadowEnabled) { CALayer *layer = self.contentViewController.view.layer; UIBezierPath *path = [UIBezierPath bezierPathWithRect:layer.bounds]; layer.shadowPath = path.CGPath; layer.shadowColor = self.contentViewShadowColor.CGColor; layer.shadowOffset = self.contentViewShadowOffset; layer.shadowOpacity = self.contentViewShadowOpacity; layer.shadowRadius = self.contentViewShadowRadius; } } #pragma mark - #pragma mark UIGestureRecognizer Delegate (Private) - (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer { CGPoint translation = [gestureRecognizer translationInView:self.view]; if (self.isLeftMenuVisible) { if (translation.x > 0) { return NO; } } else if (translation.x <= 0) { return NO; } return fabs(translation.y) < fabs(translation.x); } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if(![self isPreiOS8]){ if (self.interactivePopGestureRecognizerEnabled && [self.contentViewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navigationController = (UINavigationController *)self.contentViewController; if (navigationController.viewControllers.count > 1 && navigationController.interactivePopGestureRecognizer.enabled) { return NO; } } }else { if (self.panFromEdge && [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && !self.visible) { CGPoint point = [touch locationInView:gestureRecognizer.view]; if (point.x < 20.0 || point.x > self.view.frame.size.width - 20.0) { return YES; } else { return NO; } } } return YES; } #pragma mark - #pragma mark Pan gesture recognizer (Private) - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer { if ([self.delegate conformsToProtocol:@protocol(ITRAirSideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:didRecognizePanGesture:)]) [self.delegate sideMenu:self didRecognizePanGesture:recognizer]; if (!self.panGestureEnabled) { return; } CGPoint point = [recognizer translationInView:self.view]; if (recognizer.state == UIGestureRecognizerStateBegan) { [self updateContentViewShadow]; _totalAngle = 0; _lastPoint = CGPointMake(0, 0); [self addContentButton]; [self.view.window endEditing:YES]; self.didNotifyDelegate = NO; } if (recognizer.state == UIGestureRecognizerStateChanged) { CGPoint newLocationPoint = point; if(newLocationPoint.x < 0) newLocationPoint.x = 300 + newLocationPoint.x; //track movement if((newLocationPoint.x >= 0 && newLocationPoint.x <= 300)) { [self setAnchorPoint:CGPointMake(1.0, 0.5) forView:_contentViewContainer]; [self setAnchorPoint:CGPointMake(1.0, 0.5) forView:_contentViewController.view]; //calculation of scale, angle & translate for content view based on pan position CGFloat contentViewScale = 1 + (_contentViewScaleValue - 1)* (newLocationPoint.x / 300); CGFloat angle = (newLocationPoint.x - _lastPoint.x) * _contentViewRotatingAngle/300; CGFloat tranformX = newLocationPoint.x * _contentViewTranslateX/300; [UIView animateWithDuration:self.animationDuration animations:^{ _totalAngle = _totalAngle + angle; //content view scale transform CATransform3D contentScaleTransform = _contentViewContainer.layer.transform; contentScaleTransform = CATransform3DMakeScale(contentViewScale, contentViewScale,1.0f); _contentViewContainer.layer.transform = contentScaleTransform; if (angle != 0) { //content view rotate transform CATransform3D contentRotateTransform = _contentViewController.view.layer.transform; contentRotateTransform = CATransform3DMakeRotation(_totalAngle * M_PI/180.0f, 0.0f, -1.0f, 0.0f); CATransform3D sublayerTransform = _contentViewController.view.superview.layer.sublayerTransform; sublayerTransform.m34 = 1.0f / -300.0f; _contentViewController.view.superview.layer.sublayerTransform = sublayerTransform; _contentViewController.view.layer.transform = contentRotateTransform; } //content view translate transform CATransform3D contentTranslateTransform = _contentViewContainer.layer.transform; contentTranslateTransform = CATransform3DTranslate(contentTranslateTransform, tranformX, 0, 0); _contentViewContainer.layer.transform = contentTranslateTransform; //calculation of scale, angle & translate for menu view based on pan position if (angle != 0) { CGFloat menuAngle = _menuViewRotatingAngle - (newLocationPoint.x) * _menuViewRotatingAngle/300; //menu view rotate transform CATransform3D menuRotateTransform = _leftMenuViewController.view.layer.transform; menuRotateTransform = CATransform3DMakeRotation(menuAngle * M_PI/180.0f, 0.0f, -1.0f, 0.0f); CATransform3D sublayerTransform1 = _leftMenuViewController.view.superview.layer.sublayerTransform; sublayerTransform1.m34 = 1.0f / -300.0f; _leftMenuViewController.view.superview.layer.sublayerTransform = sublayerTransform1; _leftMenuViewController.view.layer.transform = menuRotateTransform; } CGFloat menuTransformValue = (_menuViewTranslateX * newLocationPoint.x/300) - _menuViewTranslateX - _menuViewContainer.frame.origin.x; //menu view translate transform CATransform3D menuTranslateTransform = _menuViewContainer.layer.transform; menuTranslateTransform = CATransform3DTranslate(menuTranslateTransform, menuTransformValue, 0, 0); _menuViewContainer.layer.transform = menuTranslateTransform; } completion:nil]; _lastPoint.x = newLocationPoint.x; } self.leftMenuViewController.view.hidden = self.contentViewContainer.frame.origin.x < 0; if (!self.leftMenuViewController && self.contentViewContainer.frame.origin.x > 0) { self.contentViewContainer.transform = CGAffineTransformIdentity; self.contentViewContainer.frame = self.view.bounds; self.visible = NO; self.isLeftMenuVisible = NO; } } if (recognizer.state == UIGestureRecognizerStateEnded) { self.didNotifyDelegate = NO; // if minimum open threshold not satisfied, left menu is closed again if (self.panMinimumOpenThreshold > 0 && (self.contentViewContainer.frame.origin.x > 0 && self.contentViewContainer.frame.origin.x < self.panMinimumOpenThreshold)) { [self hideMenuViewController]; } else if (self.contentViewContainer.frame.origin.x == 0) { [self hideMenuViewControllerAnimated:NO]; } else { if (self.contentViewContainer.frame.origin.x < 0) { [self hideMenuViewController]; } else { if (self.leftMenuViewController) { [self showLeftMenuViewController]; } } } } } #pragma mark - #pragma mark Setters - (void)setBackgroundImage:(UIImage *)backgroundImage { _backgroundImage = backgroundImage; if (self.backgroundImageView) { self.backgroundImageView.image = backgroundImage; } } - (void)setContentViewController:(UIViewController *)contentViewController { if (!_contentViewController) { _contentViewController = contentViewController; return; } [self hideViewController:_contentViewController]; contentViewController.view.layer.transform = _contentViewController.view.layer.transform; contentViewController.view.layer.sublayerTransform = _contentViewController.view.layer.sublayerTransform; _contentViewController = contentViewController; [self addChildViewController:self.contentViewController]; [self.contentViewContainer addSubview:self.contentViewController.view]; [self.contentViewController didMoveToParentViewController:self]; [self updateContentViewShadow]; // [self hideMenuViewController]; } - (void)setLeftMenuViewController:(UIViewController *)leftMenuViewController { if (!_leftMenuViewController) { _leftMenuViewController = leftMenuViewController; return; } [self hideViewController:_leftMenuViewController]; _leftMenuViewController = leftMenuViewController; [self addChildViewController:self.leftMenuViewController]; self.leftMenuViewController.view.frame = self.view.bounds; self.leftMenuViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self.menuViewContainer addSubview:self.leftMenuViewController.view]; [self.leftMenuViewController didMoveToParentViewController:self]; } #pragma mark - Utilities - (void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view { CGPoint oldOrigin = view.frame.origin; view.layer.anchorPoint = anchorPoint; CGPoint newOrigin = view.frame.origin; CGPoint transition; transition.x = newOrigin.x - oldOrigin.x; transition.y = oldOrigin.y - oldOrigin.y; view.center = CGPointMake (view.center.x - transition.x, view.center.y - transition.y); } - (BOOL)isPreiOS8 { if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)]) { // conditionally check for any version >= iOS 8 using 'isOperatingSystemAtLeastVersion' return NO; } return YES; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/ITRAirSideMenu/ITRAirSideMenu.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
5,416
```objective-c // // JCFlipPageView.m // JCFlipPageView // // Created by Jimple on 14-8-7. // #import "JCFlipPageView.h" #import "JCFlipViewAnimationHelper.h" #import "JCFlipPage.h" static NSUInteger kReusableArraySize = 20; @interface JCFlipPageView () < JCFlipViewAnimationHelperDataSource, JCFlipViewAnimationHelperDelegate > @property (nonatomic, strong) JCFlipViewAnimationHelper *flipAnimationHelper; @property (nonatomic, assign) NSUInteger numberOfPages; @property (nonatomic, strong) JCFlipPage *currPage; @property (nonatomic, assign) NSUInteger currIndex; @property (nonatomic, strong) NSMutableDictionary *reusablePagesDic; @property (nonatomic, strong) NSMutableDictionary *pageIndexStr2SnapshotImgDic; @property (nonatomic, strong) UIView *backgroundPageView; @end @implementation JCFlipPageView @synthesize dataSource; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code [self initalizeView]; } return self; } - (void)awakeFromNib { [super awakeFromNib]; [self initalizeView]; } - (void)dealloc { if (_currPage) { [_currPage removeFromSuperview]; }else{} } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ - (NSInteger)currPageIndex { return _currIndex; } - (void)reloadData { [self cleanupPages]; _currIndex = -1; _numberOfPages = [self pagesCount]; if (_numberOfPages > 0) { [self flipToPageAtIndex:0 animation:NO forceFlip:YES durantion:0.3f]; }else{} } - (void)flipToPageAtIndex:(NSUInteger)pageNumber animation:(BOOL)animation duration:(CGFloat)duration { [self flipToPageAtIndex:pageNumber animation:animation forceFlip:YES durantion:duration]; } - (void)flipToPageAtIndex:(NSUInteger)pageNumber animation:(BOOL)animation { [self flipToPageAtIndex:pageNumber animation:animation forceFlip:NO durantion:0.3f]; } - (void)flipToPageAtIndex:(NSUInteger)pageNumber animation:(BOOL)animation forceFlip:(BOOL)forceFlip durantion:(CGFloat)duration { if (forceFlip || ((pageNumber < _numberOfPages) && (pageNumber != _currIndex))) { if (animation) { BOOL canDoFilpAnimation = NO; if (pageNumber == _currIndex) {// if (_currIndex >= 1) { [self filpToIndexWithoutAnimation:(_currIndex-1)]; canDoFilpAnimation = YES; } else if ((_currIndex + 1) < _numberOfPages) { [self filpToIndexWithoutAnimation:(_currIndex+1)]; canDoFilpAnimation = YES; } else { canDoFilpAnimation = NO; } }else{} if (canDoFilpAnimation) { [_flipAnimationHelper flipToDirection:((_currIndex > pageNumber) ? kEFlipDirectionToPrePage : kEFlipDirectionToNextPage) toPageNum:pageNumber duration:duration]; }else{} } else { [self filpToIndexWithoutAnimation:pageNumber]; } }else{} } - (void)filpToIndexWithoutAnimation:(NSUInteger)destPageNumber { if (_currPage) { [self recoveryPage:_currPage]; }else{} _currPage = nil; _currPage = [self.dataSource flipPageView:self pageAtIndex:destPageNumber]; [[self reusableViewsWithReuseIdentifier:_currPage.reuseIdentifier] removeObject:_currPage]; [self addSubview:_currPage]; _currIndex = destPageNumber; } - (JCFlipPage *)dequeueReusablePageWithReuseIdentifier:(NSString *)reuseIdentifier { JCFlipPage *page = [[self reusableViewsWithReuseIdentifier:reuseIdentifier] anyObject]; if (page) { [[self reusableViewsWithReuseIdentifier:reuseIdentifier] removeObject:page]; }else{} return page; } - (void)initializeBackgroundPageView:(UIView *)bgView { _backgroundPageView = bgView; if (_flipAnimationHelper) { [_flipAnimationHelper resetBackgroundPageView:_backgroundPageView]; }else{} } - (void)initializeBackgroundPageViewWithBgColor:(UIColor *)bgColor { NSAssert(bgColor, @""); if (!bgColor) { bgColor = [UIColor clearColor]; }else{} _backgroundPageView = [[UIView alloc] initWithFrame:self.bounds]; _backgroundPageView.backgroundColor = bgColor; if (_flipAnimationHelper) { [_flipAnimationHelper resetBackgroundPageView:_backgroundPageView]; }else{} } #pragma mark - JCFlipViewAnimationHelperDataSource - (UIView *)flipViewAnimationHelperGetPreView:(JCFlipViewAnimationHelper *)helper { UIView *preView; if (_currIndex > 0) { preView = [self.dataSource flipPageView:self pageAtIndex:_currIndex-1]; }else{} return preView; } - (UIView *)flipViewAnimationHelperGetCurrentView:(JCFlipViewAnimationHelper *)helper { return _currPage; } - (UIView *)flipViewAnimationHelperGetNextView:(JCFlipViewAnimationHelper *)helper { UIView *nextView; if (_currIndex < (_numberOfPages - 1)) { nextView = [self.dataSource flipPageView:self pageAtIndex:_currIndex+1]; }else{} return nextView; } - (NSInteger)flipViewAnimationHelperGetCurrentPageIndex:(JCFlipViewAnimationHelper *)helper { return _currIndex; } - (UIView *)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper getPageByNum:(NSUInteger)pageNum { UIView *pageView; if (pageNum < _numberOfPages) { pageView = [self.dataSource flipPageView:self pageAtIndex:pageNum]; }else{} return pageView; } - (UIImage *)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper getSnapshotForPageIndex:(NSInteger)index { return _pageIndexStr2SnapshotImgDic[@(index).stringValue]; } #pragma mark - JCFlipViewAnimationHelperDelegate - (void)flipViewAnimationHelperBeginAnimation:(JCFlipViewAnimationHelper *)helper { _currPage.hidden = YES; } - (void)flipViewAnimationHelperEndAnimation:(JCFlipViewAnimationHelper *)helper { _currPage.hidden = NO; } - (void)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper flipCompletedToDirection:(EFlipDirection)direction { NSUInteger newIndex = _currIndex; switch (direction) { case kEFlipDirectionToPrePage: { if (_currIndex >= 1) { newIndex = _currIndex - 1; } else { newIndex = 0; } } break; case kEFlipDirectionToNextPage: { if (_currIndex <= (_numberOfPages - 2)) { newIndex = _currIndex + 1; } else { newIndex = _numberOfPages - 1; } } break; default: break; } [self showPage:newIndex]; } - (void)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper flipCompletedToPage:(NSUInteger)pageNum { [self showPage:pageNum]; } - (void)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper pageSnapshot:(UIImage *)snapshot forPageIndex:(NSInteger)index { if (self.cachePageSnapshotImage && snapshot) { _pageIndexStr2SnapshotImgDic[@(index).stringValue] = snapshot; }else{} } #pragma mark - - (void)initalizeView { _pageIndexStr2SnapshotImgDic = [[NSMutableDictionary alloc] init]; _flipAnimationHelper = [[JCFlipViewAnimationHelper alloc] initWithHostView:self backgroundPageView:_backgroundPageView]; _flipAnimationHelper.dataSource = self; _flipAnimationHelper.delegate = self; _currIndex = -1; _numberOfPages = 0; } - (void)cleanupPages { _numberOfPages = 0; if (_currPage) { [self recoveryPage:_currPage]; }else{} _currPage = nil; _pageIndexStr2SnapshotImgDic = [[NSMutableDictionary alloc] init]; } - (NSUInteger)pagesCount { NSInteger count = 0; count = [self.dataSource numberOfPagesInFlipPageView:self]; return count; } - (NSMutableSet *)reusableViewsWithReuseIdentifier:(NSString *)reuseIdentifier { if (!_reusablePagesDic) { _reusablePagesDic = [[NSMutableDictionary alloc] init]; }else{} NSString *reuseID = reuseIdentifier ? reuseIdentifier : kJCFlipPageDefaultReusableIdentifier; NSMutableSet *reusablePages = [_reusablePagesDic objectForKey:reuseID]; if (!reusablePages) { reusablePages = [[NSMutableSet alloc] init]; [_reusablePagesDic setObject:reusablePages forKey:reuseID]; } return reusablePages; } - (void)recoveryPage:(JCFlipPage *)page { if (page) { if ([self reusableViewsWithReuseIdentifier:_currPage.reuseIdentifier].count < kReusableArraySize) { [[self reusableViewsWithReuseIdentifier:_currPage.reuseIdentifier] addObject:page]; }else{} [page removeFromSuperview]; page = nil; }else{} } - (void)showPage:(CGFloat)pageIndex { if (pageIndex != _currIndex) { _currIndex = pageIndex; if (_currPage) { [self recoveryPage:_currPage]; }else{} _currPage = [self.dataSource flipPageView:self pageAtIndex:pageIndex]; [self addSubview:_currPage]; }else{} } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/JCFlipPageView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
2,230
```objective-c // // JCFlipPageView.h // JCFlipPageView // // Created by Jimple on 14-8-7. // #import <UIKit/UIKit.h> @class JCFlipPage; @protocol JCFlipPageViewDataSource; @interface JCFlipPageView : UIView @property (nonatomic, weak) id<JCFlipPageViewDataSource> dataSource; @property (nonatomic, assign) BOOL cachePageSnapshotImage; // - (NSInteger)currPageIndex; - (void)reloadData; - (void)flipToPageAtIndex:(NSUInteger)pageNumber animation:(BOOL)animation; - (void)flipToPageAtIndex:(NSUInteger)pageNumber animation:(BOOL)animation duration:(CGFloat)duration; - (JCFlipPage *)dequeueReusablePageWithReuseIdentifier:(NSString *)reuseIdentifier; - (void)initializeBackgroundPageView:(UIView *)bgView; - (void)initializeBackgroundPageViewWithBgColor:(UIColor *)bgColor; @end @protocol JCFlipPageViewDataSource <NSObject> - (NSUInteger)numberOfPagesInFlipPageView:(JCFlipPageView *)flipPageView; - (JCFlipPage *)flipPageView:(JCFlipPageView *)flipPageView pageAtIndex:(NSUInteger)index; @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/JCFlipPageView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
250
```objective-c // // JCFlipViewAnimationHelper.h // JCFlipPageView // // Created by Jimple on 14-8-8. // #import <Foundation/Foundation.h> typedef NS_ENUM(NSUInteger, EFlipDirection) { kEFlipDirectionToPrePage = 0, kEFlipDirectionToNextPage }; @protocol JCFlipViewAnimationHelperDataSource; @protocol JCFlipViewAnimationHelperDelegate; @interface JCFlipViewAnimationHelper : NSObject @property (nonatomic, weak) id<JCFlipViewAnimationHelperDataSource> dataSource; @property (nonatomic, weak) id<JCFlipViewAnimationHelperDelegate> delegate; - (instancetype)initWithHostView:(UIView *)hostView backgroundPageView:(UIView *)bgPageView; - (void)resetBackgroundPageView:(UIView *)bgView; - (void)flipToDirection:(EFlipDirection)direction toPageNum:(NSUInteger)pageNum; - (void)flipToDirection:(EFlipDirection)direction toPageNum:(NSUInteger)pageNum duration:(CGFloat)duration; @end @protocol JCFlipViewAnimationHelperDataSource <NSObject> - (UIView *)flipViewAnimationHelperGetPreView:(JCFlipViewAnimationHelper *)helper; - (UIView *)flipViewAnimationHelperGetCurrentView:(JCFlipViewAnimationHelper *)helper; - (UIView *)flipViewAnimationHelperGetNextView:(JCFlipViewAnimationHelper *)helper; - (UIView *)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper getPageByNum:(NSUInteger)pageNum; - (NSInteger)flipViewAnimationHelperGetCurrentPageIndex:(JCFlipViewAnimationHelper *)helper; - (UIImage *)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper getSnapshotForPageIndex:(NSInteger)index; @end @protocol JCFlipViewAnimationHelperDelegate <NSObject> - (void)flipViewAnimationHelperBeginAnimation:(JCFlipViewAnimationHelper *)helper; - (void)flipViewAnimationHelperEndAnimation:(JCFlipViewAnimationHelper *)helper; - (void)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper flipCompletedToDirection:(EFlipDirection)direction; - (void)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper flipCompletedToPage:(NSUInteger)pageNum; - (void)flipViewAnimationHelper:(JCFlipViewAnimationHelper *)helper pageSnapshot:(UIImage *)snapshot forPageIndex:(NSInteger)index; @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/JCFlipViewAnimationHelper.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
485
```objective-c // // JCFlipViewAnimationHelper.m // JCFlipPageView // // Created by Jimple on 14-8-8. // #import "JCFlipViewAnimationHelper.h" #import "SBGradientOverlayLayer.h" // layerSBTickerView path_to_url #define kDefaultBgPageColor [UIColor darkGrayColor] #define kProgressAnimationDuration 0.5f #define kSwipeReduceRate 0.8f #define kFlipToBgMaxProgress 0.3f @interface JCFlipViewAnimationHelper () @property (nonatomic, weak) UIView *hostView; @property (nonatomic, strong) UIPanGestureRecognizer *panGesture; @property (nonatomic, assign) BOOL canBeginAnimateWithPan; @property (nonatomic, assign) BOOL isAnimatingWithPan; @property (nonatomic, assign) BOOL isAnimationCompleted; @property (nonatomic, assign) BOOL isAnimationInited; @property (nonatomic, assign) EFlipDirection currFlipDirection; @property (nonatomic, assign) CGFloat startFlipAngle; @property (nonatomic, assign) CGFloat endFlipAngle; @property (nonatomic, assign) CGFloat currentAngle; @property (nonatomic, strong) CALayer *panelLayer; @property (nonatomic, strong) CATransformLayer *flipLayer; @property (nonatomic, strong) SBGradientOverlayLayer *bgTopLayer; @property (nonatomic, strong) SBGradientOverlayLayer *bgBottomLayer; @property (nonatomic, strong) SBGradientOverlayLayer *flipFrontSubLayer; @property (nonatomic, strong) SBGradientOverlayLayer *flipBackSubLayer; @property (nonatomic, strong) UIImage *backgroundPageSnapshot; @property (nonatomic, strong) UIView *bgPageView; @property (nonatomic, assign) BOOL isFilpToBg; @end @implementation JCFlipViewAnimationHelper @synthesize dataSource; @synthesize delegate; - (instancetype)initWithHostView:(UIView *)hostView backgroundPageView:(UIView *)bgPageView { self = [super init]; if (self) { NSAssert(hostView, @""); _hostView = hostView; _panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)]; [_hostView addGestureRecognizer:_panGesture]; _canBeginAnimateWithPan = YES; _isAnimationCompleted = YES; _isAnimatingWithPan = NO; _isAnimationInited = NO; _isFilpToBg = NO; [self resetBackgroundPageView:bgPageView]; }else{} return self; } - (void)dealloc { [_hostView removeGestureRecognizer:_panGesture]; [self clearLayers]; } - (void)resetBackgroundPageView:(UIView *)bgView { _bgPageView = bgView; [self initializeBgPageSnapshot]; } - (void)flipToDirection:(EFlipDirection)direction toPageNum:(NSUInteger)pageNum { [self flipToDirection:direction toPageNum:pageNum duration:0.3f]; } - (void)flipToDirection:(EFlipDirection)direction toPageNum:(NSUInteger)pageNum duration:(CGFloat)duration { [self clearLayers]; _canBeginAnimateWithPan = YES; _isAnimationCompleted = YES; _isAnimatingWithPan = NO; _isAnimationInited = NO; _currFlipDirection = direction; [self beginFlipAnimationForDirection:_currFlipDirection flipToDestPage:YES destPageNum:pageNum]; _canBeginAnimateWithPan = NO; _isAnimationCompleted = NO; [self performSelector:@selector(delayShowFlipAnimation:) withObject:@[@(duration), @(pageNum)] afterDelay:0.01f]; } - (void)delayShowFlipAnimation:(NSArray *)paramArray { NSNumber *duration = paramArray[0]; NSNumber *pageNum = paramArray[1]; [self progressFlipAnimation:1.0f duration:duration.floatValue cleanupWhenCompleted:YES isDelegatePageNum:YES destPageNum:pageNum.unsignedIntegerValue]; } #pragma mark - Gesture handler - (void)panGestureHandler:(UIPanGestureRecognizer *)recognizer { if (!_canBeginAnimateWithPan) { return; }else{} CGFloat translationY = [recognizer translationInView:_hostView].y; switch (recognizer.state) { case UIGestureRecognizerStateBegan: { if (_isAnimationCompleted) { _isAnimationCompleted = NO; _isAnimatingWithPan = YES; }else{} } break; case UIGestureRecognizerStateChanged: { if (_isAnimatingWithPan) { BOOL canProgressAnimation = YES; if (!_isAnimationInited) { _currFlipDirection = ((translationY > 0.0f) ? kEFlipDirectionToPrePage : kEFlipDirectionToNextPage); canProgressAnimation = [self beginFlipAnimationForDirection:_currFlipDirection]; }else{} if (canProgressAnimation) { CGFloat progress = translationY / (_hostView.bounds.size.height * kSwipeReduceRate); // height * 1 switch (_currFlipDirection) { case kEFlipDirectionToPrePage: { progress = MAX(progress, 0); progress = MIN(progress, 1.0f); } break; case kEFlipDirectionToNextPage: { progress = MIN(progress, 0); progress = MAX(progress, -1.0f); } break; default: break; } progress = fabs(progress); // // if (_isFilpToBg) { progress = progress * kFlipToBgMaxProgress; }else{} [self progressFlipAnimation:progress]; } else { [self endFlipAnimation]; } }else{} } break; case UIGestureRecognizerStateCancelled: { if (_isAnimatingWithPan) { [self progressFlipAnimation:0.0f cleanupWhenCompleted:YES]; }else{} } break; case UIGestureRecognizerStateFailed: { if (_isAnimatingWithPan) { [self endFlipAnimation]; }else{} } break; case UIGestureRecognizerStateEnded: { if (_isAnimatingWithPan) { if (_isFilpToBg) { [self progressFlipAnimation:0.0f cleanupWhenCompleted:YES]; } else { // if (fabs((translationY + [recognizer velocityInView:_hostView].y / 4) / _hostView.bounds.size.height) > 0.5f) { [self progressFlipAnimation:1.0f cleanupWhenCompleted:YES]; } else { [self progressFlipAnimation:0.0f cleanupWhenCompleted:YES]; } } }else{} } break; default: { } break; } } #pragma mark - - (BOOL)beginFlipAnimationForDirection:(EFlipDirection)direction { return [self beginFlipAnimationForDirection:direction flipToDestPage:NO destPageNum:0]; } - (BOOL)beginFlipAnimationForDirection:(EFlipDirection)direction flipToDestPage:(BOOL)isFlipToDestPage destPageNum:(NSUInteger)destPageNum { BOOL canFlipPage = NO; NSAssert(self.dataSource, @""); // UIView *currView; UIView *preView; UIView *nextView; NSInteger currViewIndex = [self.dataSource flipViewAnimationHelperGetCurrentPageIndex:self]; NSInteger preViewIndex = currViewIndex - 1; NSInteger nextViewIndex = currViewIndex + 1; currView = [self.dataSource flipViewAnimationHelperGetCurrentView:self]; switch (direction) { case kEFlipDirectionToPrePage: { if (isFlipToDestPage) { preView = [self.dataSource flipViewAnimationHelper:self getPageByNum:destPageNum]; preViewIndex = destPageNum; } else { preView = [self.dataSource flipViewAnimationHelperGetPreView:self]; if (preView) { preViewIndex = currViewIndex - 1; }else{} } canFlipPage = (preView != nil); } break; case kEFlipDirectionToNextPage: { if (isFlipToDestPage) { nextView = [self.dataSource flipViewAnimationHelper:self getPageByNum:destPageNum]; nextViewIndex = destPageNum; } else { nextView = [self.dataSource flipViewAnimationHelperGetNextView:self]; if (nextView) { nextViewIndex = currViewIndex + 1; }else{} } canFlipPage = (nextView != nil); } break; default: break; } // _isFilpToBg = NO; if (!canFlipPage && !isFlipToDestPage) { if (direction == kEFlipDirectionToPrePage) { preView = _bgPageView; canFlipPage = YES; _isFilpToBg = YES; } else if (direction == kEFlipDirectionToNextPage) { nextView = _bgPageView; canFlipPage = YES; _isFilpToBg = YES; }else{} }else{} if ((currViewIndex < 0) || !currView) { canFlipPage = NO; }else{} // layer if (canFlipPage && currView) { [self rebulidLayers]; _bgTopLayer.contentsGravity = kCAGravityBottom; _bgBottomLayer.contentsGravity = kCAGravityTop; _flipFrontSubLayer.contentsGravity = kCAGravityBottom; _flipBackSubLayer.contentsGravity = kCAGravityTop; switch (direction) { case kEFlipDirectionToPrePage: { UIImage *preImg; if (preView == _bgPageView) { preImg = _backgroundPageSnapshot; } else { preImg = [self.dataSource flipViewAnimationHelper:self getSnapshotForPageIndex:preViewIndex]; if (!preImg) { preImg = [self snapshotFromView:preView]; [self.delegate flipViewAnimationHelper:self pageSnapshot:preImg forPageIndex:preViewIndex]; }else{} } UIImage *currImg = [self snapshotFromView:currView]; if (!currImg) { currImg = [self snapshotFromView:currView]; [self.delegate flipViewAnimationHelper:self pageSnapshot:currImg forPageIndex:currViewIndex]; }else{} [_bgTopLayer setContents:(__bridge id)preImg.CGImage]; [_bgBottomLayer setContents:(__bridge id)currImg.CGImage]; [_flipFrontSubLayer setContents:(__bridge id)currImg.CGImage]; [_flipBackSubLayer setContents:(__bridge id)preImg.CGImage]; [_flipLayer setTransform:CATransform3DIdentity]; _currentAngle = _startFlipAngle = 0.0f; _endFlipAngle = -M_PI; } break; case kEFlipDirectionToNextPage: { UIImage *nextImg; if (nextView == _bgPageView) { nextImg = _backgroundPageSnapshot; } else { nextImg = [self.dataSource flipViewAnimationHelper:self getSnapshotForPageIndex:nextViewIndex]; if (!nextImg) { nextImg = [self snapshotFromView:nextView]; [self.delegate flipViewAnimationHelper:self pageSnapshot:nextImg forPageIndex:nextViewIndex]; }else{} } UIImage *currImg = [self snapshotFromView:currView]; if (!currImg) { currImg = [self snapshotFromView:currView]; [self.delegate flipViewAnimationHelper:self pageSnapshot:currImg forPageIndex:currViewIndex]; }else{} [_bgTopLayer setContents:(__bridge id)currImg.CGImage]; [_bgBottomLayer setContents:(__bridge id)nextImg.CGImage]; [_flipFrontSubLayer setContents:(__bridge id)nextImg.CGImage]; [_flipBackSubLayer setContents:(__bridge id)currImg.CGImage]; [_flipLayer setTransform:CATransform3DMakeRotation(-M_PI, 1., 0., 0.)]; _currentAngle = _startFlipAngle = -M_PI; _endFlipAngle = 0.0f; } break; default: break; } _isAnimationInited = YES; if (delegate && [delegate respondsToSelector:@selector(flipViewAnimationHelperBeginAnimation:)]) { [delegate flipViewAnimationHelperBeginAnimation:self]; }else{} }else{} return canFlipPage; } - (void)progressFlipAnimation:(CGFloat)progress { [self progressFlipAnimation:progress cleanupWhenCompleted:NO]; } - (void)progressFlipAnimation:(CGFloat)progress cleanupWhenCompleted:(BOOL)isCleanupWhenCompleted { [self progressFlipAnimation:progress duration:0.0f cleanupWhenCompleted:isCleanupWhenCompleted]; } - (void)progressFlipAnimation:(CGFloat)progress duration:(CGFloat)animationDuration cleanupWhenCompleted:(BOOL)isCleanupWhenCompleted { [self progressFlipAnimation:progress duration:animationDuration cleanupWhenCompleted:isCleanupWhenCompleted isDelegatePageNum:NO destPageNum:0]; } - (void)progressFlipAnimation:(CGFloat)progress duration:(CGFloat)animationDuration cleanupWhenCompleted:(BOOL)isCleanupWhenCompleted isDelegatePageNum:(BOOL)isDelegatePageNum destPageNum:(NSUInteger)destPageNum { CGFloat newAngle = _startFlipAngle + progress * (_endFlipAngle - _startFlipAngle); CATransform3D endTransform = CATransform3DIdentity; endTransform.m34 = 1.0f / 2500.0f; endTransform = CATransform3DRotate(endTransform, newAngle, -1.0, 0.0, 0.0); CGFloat duration = (animationDuration > 0.0f) ? animationDuration : (kProgressAnimationDuration * fabs((newAngle - _currentAngle) / (_endFlipAngle - _startFlipAngle))); _currentAngle = newAngle; [_flipLayer removeAllAnimations]; [CATransaction begin]; [CATransaction setAnimationDuration:duration]; if (isCleanupWhenCompleted) { __weak __typeof(self)weakSelf = self; [CATransaction setCompletionBlock:^{ __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf endFlipAnimation]; if (progress >= 1.0f) { if (isDelegatePageNum) { if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(flipViewAnimationHelper:flipCompletedToPage:)]) { [strongSelf.delegate flipViewAnimationHelper:self flipCompletedToPage:destPageNum]; }else{} } else if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(flipViewAnimationHelper:flipCompletedToDirection:)]) { [strongSelf.delegate flipViewAnimationHelper:self flipCompletedToDirection:_currFlipDirection]; }else{} }else{} }]; }else{} _flipLayer.transform = endTransform; // if (_startFlipAngle == 0.0f) {// _bgTopLayer.gradientOpacity = 1.0f -progress; _bgBottomLayer.gradientOpacity = progress; _flipFrontSubLayer.gradientOpacity = progress; _flipBackSubLayer.gradientOpacity = 1.0f - progress; } else {// _bgTopLayer.gradientOpacity = progress; _bgBottomLayer.gradientOpacity = 1.0f - progress; _flipFrontSubLayer.gradientOpacity = 1.0f - progress; _flipBackSubLayer.gradientOpacity = progress; } [CATransaction commit]; } - (void)endFlipAnimation { [self clearLayers]; _canBeginAnimateWithPan = YES; _isAnimationCompleted = YES; _isAnimatingWithPan = NO; _isAnimationInited = NO; _isFilpToBg = NO; if (delegate && [delegate respondsToSelector:@selector(flipViewAnimationHelperEndAnimation:)]) { [delegate flipViewAnimationHelperEndAnimation:self]; }else{} } - (void)clearLayers { if (_bgTopLayer) { [_bgTopLayer removeFromSuperlayer]; _bgTopLayer = nil; }else{} if (_bgBottomLayer) { [_bgBottomLayer removeFromSuperlayer]; _bgBottomLayer = nil; }else{} if (_flipFrontSubLayer) { [_flipFrontSubLayer removeFromSuperlayer]; _flipFrontSubLayer = nil; }else{} if (_flipBackSubLayer) { [_flipBackSubLayer removeFromSuperlayer]; _flipBackSubLayer = nil; }else{} if (_flipLayer) { [_flipLayer removeAllAnimations]; [_flipLayer removeFromSuperlayer]; _flipLayer = nil; }else{} if (_panelLayer) { [_panelLayer removeFromSuperlayer]; _panelLayer = nil; }else{} } - (void)rebulidLayers { [self clearLayers]; _panelLayer = [CALayer layer]; _panelLayer.frame = _hostView.layer.bounds; [_hostView.layer addSublayer:_panelLayer]; _bgTopLayer = [[SBGradientOverlayLayer alloc] initWithStyle:SBGradientOverlayLayerTypeFace segment:SBGradientOverlayLayerSegmentTop]; _bgTopLayer.frame = CGRectMake(0.0f, 0.0f, _panelLayer.bounds.size.width, _panelLayer.bounds.size.height/2.0f); _bgTopLayer.doubleSided = NO; _bgTopLayer.masksToBounds = YES; _bgTopLayer.contentsScale = [[UIScreen mainScreen] scale]; [_panelLayer addSublayer:_bgTopLayer]; _bgBottomLayer = [[SBGradientOverlayLayer alloc] initWithStyle:SBGradientOverlayLayerTypeFace segment:SBGradientOverlayLayerSegmentBottom]; _bgBottomLayer.frame = CGRectMake(0.0f, _panelLayer.bounds.size.height/2.0f, _panelLayer.bounds.size.width, _panelLayer.bounds.size.height/2.0f); _bgBottomLayer.doubleSided = NO; _bgBottomLayer.masksToBounds = YES; _bgBottomLayer.contentsScale = [[UIScreen mainScreen] scale]; [_panelLayer addSublayer:_bgBottomLayer]; _flipLayer = [CATransformLayer layer]; _flipLayer.doubleSided = YES; _flipLayer.anchorPoint = CGPointMake(1., 1.); _flipLayer.frame = CGRectMake(0.0f, 0.0f, _panelLayer.frame.size.width, (_panelLayer.frame.size.height/2)); _flipLayer.zPosition = 1000.0f; // Above the other ones [_panelLayer addSublayer:_flipLayer]; _flipFrontSubLayer = [[SBGradientOverlayLayer alloc] initWithStyle:SBGradientOverlayLayerTypeFace segment:SBGradientOverlayLayerSegmentTop]; _flipFrontSubLayer.frame = _flipLayer.bounds; _flipFrontSubLayer.doubleSided = NO; _flipFrontSubLayer.masksToBounds = YES; _flipFrontSubLayer.contentsScale = [[UIScreen mainScreen] scale]; [_flipLayer addSublayer:_flipFrontSubLayer]; _flipBackSubLayer = [[SBGradientOverlayLayer alloc] initWithStyle:SBGradientOverlayLayerTypeFace segment:SBGradientOverlayLayerSegmentBottom]; _flipFrontSubLayer.frame = _flipLayer.bounds; _flipBackSubLayer.frame = _flipLayer.bounds; _flipBackSubLayer.doubleSided = NO; _flipBackSubLayer.masksToBounds = YES; _flipBackSubLayer.contentsScale = [[UIScreen mainScreen] scale]; CATransform3D transform = CATransform3DMakeRotation(M_PI, 1., 0., 0.); [_flipBackSubLayer setTransform:transform]; [_flipLayer addSublayer:_flipBackSubLayer]; } - (UIImage*)snapshotFromView:(UIView *)view { UIImage *image = nil; UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } - (void)initializeBgPageSnapshot { if (!_bgPageView) { _bgPageView = [[UIView alloc] initWithFrame:_hostView.bounds]; _bgPageView.backgroundColor = kDefaultBgPageColor; }else{} _backgroundPageSnapshot = [self snapshotFromView:_bgPageView]; } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/JCFlipViewAnimationHelper.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
4,626
```objective-c // // -------------------------------------------- // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // -------------------------------------------- // // SBGradientOverlayLayer.h // SBTickerView // // Created by Simon Blommegrd on 2011-12-10. // #import <QuartzCore/QuartzCore.h> typedef enum { SBGradientOverlayLayerTypeFace, SBGradientOverlayLayerTypeTick } SBGradientOverlayLayerType; typedef enum { SBGradientOverlayLayerSegmentTop, SBGradientOverlayLayerSegmentBottom } SBGradientOverlayLayerSegment; @interface SBGradientOverlayLayer : CALayer @property (nonatomic, readonly) SBGradientOverlayLayerType type; @property (nonatomic, readonly) SBGradientOverlayLayerSegment segment; @property (nonatomic) CGFloat gradientOpacity; - (id)initWithStyle:(SBGradientOverlayLayerType)type segment:(SBGradientOverlayLayerSegment)segment; @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/SBGradientOverlayLayer/SBGradientOverlayLayer.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
410
```objective-c // // -------------------------------------------- // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // -------------------------------------------- // // SBGradientOverlayLayer.m // SBTickerView // // Created by Simon Blommegrd on 2011-12-10. // #import "SBGradientOverlayLayer.h" @interface SBGradientOverlayLayer () @property (nonatomic, assign) CGFloat minimumOpacity; @property (nonatomic, assign) CGFloat maximumOpacity; @property (nonatomic, strong) CAGradientLayer *gradientLayer; @property (nonatomic, strong) CALayer *gradientMaskLayer; @end @implementation SBGradientOverlayLayer @synthesize type = _type; @synthesize segment = _segment; @dynamic gradientOpacity; @synthesize minimumOpacity = _minimumOpacity; @synthesize maximumOpacity = _maximumOpacity; @synthesize gradientLayer = _gradientLayer; @synthesize gradientMaskLayer = _gradientMaskLayer; - (id)initWithStyle:(SBGradientOverlayLayerType)type segment:(SBGradientOverlayLayerSegment)segment { if ((self = [super init])) { _type = type; _segment = segment; [self setMasksToBounds:YES]; [self addSublayer:self.gradientLayer]; [self setContentsScale:[[UIScreen mainScreen] scale]]; _minimumOpacity = 0.; [self setGradientMaskLayer:[CALayer layer]]; [_gradientMaskLayer setContentsScale:[[UIScreen mainScreen] scale]]; [_gradientLayer setMask:_gradientMaskLayer]; if (type == SBGradientOverlayLayerTypeFace) { [_gradientLayer setColors:[NSArray arrayWithObjects: (__bridge id)[UIColor colorWithWhite:0. alpha:.5].CGColor, (__bridge id)[UIColor colorWithWhite:0. alpha:1.].CGColor, nil]]; [_gradientLayer setLocations:[NSArray arrayWithObjects: [NSNumber numberWithFloat:0.], [NSNumber numberWithFloat:1.], nil]]; _maximumOpacity = .65; } else { [_gradientLayer setColors:[NSArray arrayWithObjects: (__bridge id)[UIColor colorWithWhite:0. alpha:0.].CGColor, (__bridge id)[UIColor colorWithWhite:0. alpha:.5].CGColor, (__bridge id)[UIColor colorWithWhite:0. alpha:1.].CGColor, nil]]; [_gradientLayer setLocations:[NSArray arrayWithObjects: [NSNumber numberWithFloat:.2], [NSNumber numberWithFloat:.4], [NSNumber numberWithFloat:1.], nil]]; _maximumOpacity = 0.95; } if (segment == SBGradientOverlayLayerSegmentTop) { [self setContentsGravity:kCAGravityBottom]; [_gradientLayer setStartPoint:CGPointMake(0., 0.)]; [_gradientLayer setEndPoint:CGPointMake(0., 1.)]; [_gradientMaskLayer setContentsGravity:kCAGravityBottom]; } else { [self setContentsGravity:kCAGravityTop]; [_gradientLayer setStartPoint:CGPointMake(0., 1.)]; [_gradientLayer setEndPoint:CGPointMake(0., 0.)]; [_gradientMaskLayer setContentsGravity:kCAGravityTop]; } [_gradientLayer setOpacity:_minimumOpacity]; } return self; } - (void)layoutSublayers { [super layoutSublayers]; [_gradientLayer setFrame:self.bounds]; [_gradientMaskLayer setFrame:self.bounds]; } #pragma mark - Properties - (CAGradientLayer *)gradientLayer { if (!_gradientLayer) { _gradientLayer = [[CAGradientLayer alloc] init]; [_gradientLayer setFrame:self.bounds]; } return _gradientLayer; } - (CGFloat)gradientOpacity { return _gradientLayer.opacity; } - (void)setGradientOpacity:(CGFloat)opacity { // if (opacity > 0.5f) { opacity -= 0.5f; opacity *= 2.5f; } else { opacity = 0.0f; } [_gradientLayer setOpacity:(opacity * (_maximumOpacity - _minimumOpacity) + _minimumOpacity)]; } - (void)setContents:(id)contents { [super setContents:contents]; [_gradientMaskLayer setContents:contents]; } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/FlipPageView/JCFlipPageViewClass/SBGradientOverlayLayer/SBGradientOverlayLayer.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,141
```objective-c // // RZSimpleCollectionViewController.h // RZTransitions // // Created by Stephen Barnes on 12/11/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> @interface RZSimpleCollectionViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate> @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/ViewControllers/RZSimpleCollectionViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
336
```objective-c // // RZSimpleColorViewController.h // RZTransitions // // Created by Stephen Barnes on 12/3/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> @interface RZSimpleColorViewController : UIViewController @property (nonatomic, strong) UIColor *backgroundColor; - (id)initWithColor:(UIColor *)color; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/ViewControllers/RZSimpleColorViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
337
```objective-c // // RZSimpleViewController.m // RZTransitions // // Created by Stephen Barnes on 12/3/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZSimpleViewController.h" #import "RZSimpleColorViewController.h" #import "RZSimpleCollectionViewController.h" #import "RZTransitionsInteractionControllers.h" #import "RZTransitionsAnimationControllers.h" #import "RZTransitionInteractionControllerProtocol.h" #import "RZTransitionsManager.h" @interface RZSimpleViewController () <RZTransitionInteractionControllerDelegate> @property (weak, nonatomic) IBOutlet UIButton *popButton; @property (weak, nonatomic) IBOutlet UIButton *pushButton; @property (weak, nonatomic) IBOutlet UIButton *modalButton; @property (weak, nonatomic) IBOutlet UIButton *collectionViewButton; @property (nonatomic, strong) id<RZTransitionInteractionController> pushPopInteractionController; @property (nonatomic, strong) id<RZTransitionInteractionController> presentInteractionController; @end @implementation RZSimpleViewController - (void)viewDidLoad { // navi self.navigationController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"title" style:UIBarButtonItemStylePlain target:nil action:nil]; // Create the push and pop interaction controller that allows a custom gesture // to control pushing and popping from the navigation controller self.pushPopInteractionController = [[RZHorizontalInteractionController alloc] init]; [self.pushPopInteractionController setNextViewControllerDelegate:self]; [self.pushPopInteractionController attachViewController:self withAction:RZTransitionAction_PushPop]; [[RZTransitionsManager shared] setInteractionController:self.pushPopInteractionController fromViewController:[self class] toViewController:nil forAction:RZTransitionAction_PushPop]; // Create the presentation interaction controller that allows a custom gesture // to control presenting a new VC via a presentViewController self.presentInteractionController = [[RZVerticalSwipeInteractionController alloc] init]; [self.presentInteractionController setNextViewControllerDelegate:self]; [self.presentInteractionController attachViewController:self withAction:RZTransitionAction_Present]; // Setup the push & pop animations as well as a special animation for pushing a // RZSimpleCollectionViewController [[RZTransitionsManager shared] setAnimationController:[[RZCardSlideAnimationController alloc] init] fromViewController:[self class] forAction:RZTransitionAction_PushPop]; [[RZTransitionsManager shared] setAnimationController:[[RZZoomPushAnimationController alloc] init] fromViewController:[self class] toViewController:[RZSimpleCollectionViewController class] forAction:RZTransitionAction_PushPop]; // Setup the animations for presenting and dismissing a new VC [[RZTransitionsManager shared] setAnimationController:[[RZCirclePushAnimationController alloc] init] fromViewController:[self class] forAction:RZTransitionAction_PresentDismiss]; } - (void)viewWillAppear:(BOOL)animated { [[RZTransitionsManager shared] setInteractionController:self.presentInteractionController fromViewController:[self class] toViewController:nil forAction:RZTransitionAction_Present]; } #pragma mark - Button Actions - (IBAction)pushNewViewController:(id)sender { [[self navigationController] pushViewController:[self nextSimpleViewController] animated:YES]; } - (IBAction)popViewController:(id)sender { [[self navigationController] popViewControllerAnimated:YES]; } - (IBAction)showModal:(id)sender { [self presentViewController:[self nextSimpleColorViewController] animated:YES completion:nil]; } - (IBAction)showCollectionView:(id)sender { [[self navigationController] pushViewController:[[RZSimpleCollectionViewController alloc] init] animated:YES]; } #pragma mark - Next View Controller Logic - (UIViewController *)nextSimpleViewController { RZSimpleViewController* newVC = [[RZSimpleViewController alloc] init]; [newVC setTransitioningDelegate:[RZTransitionsManager shared]]; return newVC; } - (UIViewController *)nextSimpleColorViewController { RZSimpleColorViewController* newColorVC = [[RZSimpleColorViewController alloc] init]; [newColorVC setTransitioningDelegate:[RZTransitionsManager shared]]; // Create a dismiss interaction controller that will be attached to the presented // view controller to allow for a custom dismissal RZVerticalSwipeInteractionController *dismissInteractionController = [[RZVerticalSwipeInteractionController alloc] init]; [dismissInteractionController attachViewController:newColorVC withAction:RZTransitionAction_Dismiss]; [[RZTransitionsManager shared] setInteractionController:dismissInteractionController fromViewController:[self class] toViewController:nil forAction:RZTransitionAction_Dismiss]; return newColorVC; } #pragma mark - RZTransitionInteractorDelegate - (UIViewController *)nextViewControllerForInteractor:(id<RZTransitionInteractionController>)interactor { if ([interactor isKindOfClass:[RZVerticalSwipeInteractionController class]]) { return [self nextSimpleColorViewController]; } else { return [self nextSimpleViewController]; } } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/ViewControllers/RZSimpleViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,317
```objective-c // // RZSimpleColorViewController.m // RZTransitions // // Created by Stephen Barnes on 12/3/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZSimpleColorViewController.h" #import "RZTransitionsInteractionControllers.h" #import "RZTransitionsAnimationControllers.h" #import "RZTransitionInteractionControllerProtocol.h" #import "UIColor+Random.h" @interface RZSimpleColorViewController () @property (weak, nonatomic) IBOutlet UILabel *titleLabel; @end @implementation RZSimpleColorViewController - (id)initWithColor:(UIColor *)color { self = [super init]; if (self) { if (color) { _backgroundColor = color; } } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self.view setBackgroundColor:self.backgroundColor]; UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissSelfOnTap:)]; [self.view addGestureRecognizer:tapGestureRecognizer]; } #pragma mark - Overidden Properties - (UIColor *)backgroundColor { if (!_backgroundColor) { _backgroundColor = [UIColor randomColor]; } return _backgroundColor; } #pragma mark - Handle Tap Genture Reconizer - (void)dismissSelfOnTap:(UITapGestureRecognizer *)tapGestureRecognizer { [self dismissViewControllerAnimated:YES completion:nil]; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/ViewControllers/RZSimpleColorViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
546
```objective-c // // RZSimpleViewController.h // RZTransitions // // Created by Stephen Barnes on 12/3/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> @interface RZSimpleViewController : UIViewController - (IBAction)pushNewViewController:(id)sender; - (IBAction)popViewController:(id)sender; - (IBAction)showModal:(id)sender; - (IBAction)showCollectionView:(id)sender; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/ViewControllers/RZSimpleViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
356
```objective-c // // RZCirclePushAnimationController.h // RZTransitions // // Created by Stephen Barnes on 12/13/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZZoomPushAnimationController.h" @protocol RZCirclePushAnimationDelegate <NSObject> @optional /** * Calculate the center point, in the from view controller's coordinate space, where the circle transition should be centered. If not used, the center defaults to the center of the from view controller. * * @return the circle transition's center point. */ - (CGPoint)circleCenter; /** * Calculate the radius that the circle transition should start from. If not used, the radius defaults to the minimum of the from view controller's bounds width or height. * * @return the circle transition's starting radius. */ - (CGFloat)circleStartingRadius; @end @interface RZCirclePushAnimationController : RZZoomPushAnimationController <RZAnimationControllerProtocol> @property (nonatomic, weak) id<RZCirclePushAnimationDelegate> circleDelegate; @property (nonatomic, assign) CGFloat maximumCircleScale; @property (nonatomic, assign) CGFloat minimumCircleScale; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZCirclePushAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
516
```objective-c // // RZCardSlideAnimatedTransitioning.h // RZTransitions // // Created by Nick Donaldson on 11/19/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZAnimationControllerProtocol.h" @interface RZCardSlideAnimationController : NSObject <RZAnimationControllerProtocol> @property (nonatomic, assign) CGFloat transitionTime; @property (nonatomic, assign) BOOL horizontalOrientation; @property (nonatomic, strong) UIColor *containerBackgroundColor; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZCardSlideAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
367
```objective-c // // RZSimpleCollectionViewController.m // RZTransitions // // Created by Stephen Barnes on 12/11/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZSimpleCollectionViewController.h" #import "RZSimpleColorViewController.h" #import "RZTransitionInteractionControllerProtocol.h" #import "RZTransitionsInteractionControllers.h" #import "RZTransitionsAnimationControllers.h" #import "RZRectZoomAnimationController.h" #import "RZTransitionsManager.h" #import "UIColor+Random.h" #define kRZCollectionViewCellReuseId @"kRZCollectionViewCellReuseId" #define kRZCollectionViewNumCells 50 #define kRZCollectionViewCellSize 88 @interface RZSimpleCollectionViewController () < UIViewControllerTransitioningDelegate, RZTransitionInteractionControllerDelegate, RZRectZoomAnimationDelegate > @property (nonatomic, assign) CGPoint circleTransitionStartPoint; @property (nonatomic, assign) CGRect transitionCellRect; @property (nonatomic, strong) RZOverscrollInteractionController *presentOverscrollInteractor; @property (nonatomic, strong) RZRectZoomAnimationController *presentDismissAnimationController; @end @implementation RZSimpleCollectionViewController - (void)viewDidLoad { [super viewDidLoad]; [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:kRZCollectionViewCellReuseId]; // TODO: Currently the RZOverscrollInteractor will take over the collection view's delegate, meaning that ```didSelectItemAtIndexPath:``` // will not be forwarded back. RZOverscrollInteractor requires a bit of a rewrite to use KVO instead of delegation to address this. // self.presentOverscrollInteractor = [[RZOverscrollInteractionController alloc] init]; // [self.presentOverscrollInteractor attachViewController:self withAction:RZTransitionAction_Present]; // [self.presentOverscrollInteractor setNextViewControllerDelegate:self]; // [[RZTransitionsManager shared] setInteractionController:self.presentOverscrollInteractor // fromViewController:[self class] // toViewController:nil // forAction:RZTransitionAction_Present]; self.presentDismissAnimationController = [[RZRectZoomAnimationController alloc] init]; [self.presentDismissAnimationController setRectZoomDelegate:self]; self.circleTransitionStartPoint = CGPointZero; self.transitionCellRect = CGRectZero; [[RZTransitionsManager shared] setAnimationController:self.presentDismissAnimationController fromViewController:[self class] forAction:RZTransitionAction_PresentDismiss]; [self setTransitioningDelegate:[RZTransitionsManager shared]]; } - (void)viewDidAppear:(BOOL)animated { // TODO: ** Cannot set the scroll view delegate and the collection view delegate at the same time ** // [self.presentOverscrollInteractor watchScrollView:self.collectionView]; } #pragma mark - New VC Helper Methods - (UIViewController *)newColorVCWithColor:(UIColor *)color { RZSimpleColorViewController *newColorVC = [[RZSimpleColorViewController alloc] initWithColor:color]; [newColorVC setTransitioningDelegate:[RZTransitionsManager shared]]; // TODO: Hook up next VC's dismiss transition return newColorVC; } #pragma mark - UICollectionViewDelegate - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { UIColor *cellBackgroundColor = [collectionView cellForItemAtIndexPath:indexPath].backgroundColor; UIViewController *colorVC = [self newColorVCWithColor:cellBackgroundColor]; self.circleTransitionStartPoint = [collectionView convertPoint:[collectionView cellForItemAtIndexPath:indexPath].center toView:self.view];; self.transitionCellRect = [collectionView convertRect:[collectionView cellForItemAtIndexPath:indexPath].frame toView:self.view]; // Present VC [self presentViewController:colorVC animated:YES completion:nil]; } #pragma mark - UICollectionViewDataSource - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return kRZCollectionViewNumCells; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:kRZCollectionViewCellReuseId forIndexPath:indexPath]; [cell setBackgroundColor:[UIColor randomColor]]; return cell; } #pragma mark - RZTransitionInteractorDelegate - (UIViewController *)nextViewControllerForInteractor:(id<RZTransitionInteractionController>)interactor { return [self newColorVCWithColor:nil]; } #pragma mark - RZRectZoomAnimationDelegate - (CGRect)rectZoomPosition { return self.transitionCellRect; } #pragma mark - RZCirclePushAnimationDelegate - (CGPoint)circleCenter { return self.circleTransitionStartPoint; } - (CGFloat)circleStartingRadius { return (kRZCollectionViewCellSize / 2.0f); } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/ViewControllers/RZSimpleCollectionViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,292
```objective-c // // RZShrinkTransitioner.m // RZTransitions // // Created by Nick Donaldson on 10/11/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZShrinkZoomAnimationController.h" @implementation RZShrinkZoomAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; [UIView animateWithDuration:0.5 delay:0 options:0 animations:^{ [fromViewController.view setTransform:CGAffineTransformMakeScale(0.1, 0.1)]; } completion:^(BOOL finished) { [fromViewController.view removeFromSuperview]; [toViewController.view setTransform:CGAffineTransformMakeScale(0.1, 0.1)]; [container addSubview:toViewController.view]; [UIView animateWithDuration:0.5 delay:0 options:0 animations:^{ [toViewController.view setTransform:CGAffineTransformIdentity]; } completion:^(BOOL finished) { [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; }]; } - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { return 1.0; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZShrinkZoomAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
569
```objective-c // // RZSegmentControlMoveFadeAnimatedTransitioning.m // RZTransitions // // Created by Alex Rouse on 11/5/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZSegmentControlMoveFadeAnimationController.h" #import "UIImage+RZTransitionsFastImageBlur.h" #define kRZSegAnimationTransitionTime 0.4f #define kRZSegScaleAmount 0.3f #define kRZSegXOffsetFactor 1.5f #define kRZSegYOffsetFactor 0.25f @implementation RZSegmentControlMoveFadeAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; CGAffineTransform scaleTransform = CGAffineTransformMakeScale(kRZSegScaleAmount, kRZSegScaleAmount); CGAffineTransform oldTranslateTransform; CGAffineTransform newTranslateTransform; // Animate to the right if (self.isPositiveAnimation) { oldTranslateTransform = CGAffineTransformMakeTranslation(container.bounds.size.width*kRZSegXOffsetFactor, -container.bounds.size.height*kRZSegYOffsetFactor); newTranslateTransform = CGAffineTransformMakeTranslation(-container.bounds.size.width*kRZSegXOffsetFactor, -container.bounds.size.height*kRZSegYOffsetFactor); } // Animate to the left else { oldTranslateTransform = CGAffineTransformMakeTranslation(-container.bounds.size.width*kRZSegXOffsetFactor, -container.bounds.size.height*kRZSegYOffsetFactor); newTranslateTransform = CGAffineTransformMakeTranslation(container.bounds.size.width*kRZSegXOffsetFactor, -container.bounds.size.height*kRZSegYOffsetFactor); } [container insertSubview:toViewController.view aboveSubview:fromViewController.view]; toViewController.view.alpha = 0.1f; toViewController.view.transform = CGAffineTransformConcat(newTranslateTransform, scaleTransform); [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ toViewController.view.transform = CGAffineTransformIdentity; toViewController.view.alpha = 1.0f; fromViewController.view.transform = CGAffineTransformConcat(oldTranslateTransform, scaleTransform); fromViewController.view.alpha = 0.1f; } completion:^(BOOL finished) { [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { return kRZSegAnimationTransitionTime; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZSegmentControlMoveFadeAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
858
```objective-c // // RZZoomAlphaAnimationController.h // RZTransitions // // Created by Stephen Barnes on 2/12/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZAnimationControllerProtocol.h" @interface RZZoomAlphaAnimationController : NSObject <RZAnimationControllerProtocol> @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZZoomAlphaAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
334
```objective-c // // RZCirclePushAnimationController.m // RZTransitions // // Created by Stephen Barnes on 12/13/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZCirclePushAnimationController.h" #define kRZCircleDefaultMaxScale 2.5f #define kRZCircleDefaultMinScale 0.25f #define kRZCircleAnimationTime 0.5f #define kRZCircleMaskAnimation @"kRZCircleMaskAnimation" @interface RZCirclePushAnimationController () - (CGPoint)circleCenterPointWithFromViewController:(UIViewController *)fromViewController; - (CGFloat)circleStartingRadiusWithFromViewController:(UIViewController *)fromViewController withToViewController:(UIViewController *)toViewController; @end @implementation RZCirclePushAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; #pragma mark - Animation Transition - (id)init { self = [super init]; if (self) { _minimumCircleScale = kRZCircleDefaultMinScale; _maximumCircleScale = kRZCircleDefaultMaxScale; } return self; } - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; CGRect bounds = toViewController.view.bounds; CAShapeLayer *circleMaskLayer = [CAShapeLayer layer]; circleMaskLayer.frame = bounds; // Caclulate the size the circle should start at CGFloat radius = [self circleStartingRadiusWithFromViewController:fromViewController withToViewController:toViewController]; // Caclulate the center point of the circle CGPoint circleCenter = [self circleCenterPointWithFromViewController:fromViewController]; circleMaskLayer.position = circleCenter; CGRect circleBoundingRect = CGRectMake(circleCenter.x - radius, circleCenter.y - radius, 2.0*radius, 2.0*radius); circleMaskLayer.path = [UIBezierPath bezierPathWithOvalInRect:circleBoundingRect].CGPath; circleMaskLayer.bounds = circleBoundingRect; CABasicAnimation *circleMaskAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; circleMaskAnimation.duration = kRZCircleAnimationTime; circleMaskAnimation.repeatCount = 1.0; // Animate only once circleMaskAnimation.removedOnCompletion = NO; // Remain after the animation // Set manual easing on the animation. Tweak for fun! [circleMaskAnimation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.34 :.01 :.69 :1.37]]; if (self.isPositiveAnimation) { [circleMaskAnimation setFillMode:kCAFillModeForwards]; // Animate from small to large circleMaskAnimation.fromValue = [NSNumber numberWithFloat:self.minimumCircleScale]; circleMaskAnimation.toValue = [NSNumber numberWithFloat:self.maximumCircleScale]; // Add to the view and start the animation [toViewController.view.layer setMask:circleMaskLayer]; toViewController.view.layer.masksToBounds = YES; [circleMaskLayer addAnimation:circleMaskAnimation forKey:kRZCircleMaskAnimation]; } else { [circleMaskAnimation setFillMode:kCAFillModeForwards]; // Animate from large to small circleMaskAnimation.fromValue = [NSNumber numberWithFloat:1.0f]; circleMaskAnimation.toValue = [NSNumber numberWithFloat:self.minimumCircleScale]; // Add to the view and start the animation [fromViewController.view.layer setMask:circleMaskLayer]; fromViewController.view.layer.masksToBounds = YES; [circleMaskLayer addAnimation:circleMaskAnimation forKey:kRZCircleMaskAnimation]; } [super animateTransition:transitionContext]; } #pragma mark - Helper Methods // Caclulate the center point of the circle - (CGPoint)circleCenterPointWithFromViewController:(UIViewController *)fromViewController { CGPoint center = CGPointZero; if (self.circleDelegate && [self.circleDelegate respondsToSelector:@selector(circleCenter)]) { center = [self.circleDelegate circleCenter]; } else { center = CGPointMake(fromViewController.view.bounds.origin.x + fromViewController.view.bounds.size.width / 2, fromViewController.view.bounds.origin.y + fromViewController.view.bounds.size.height / 2); } return center; } // Caclulate the size the circle should start at - (CGFloat)circleStartingRadiusWithFromViewController:(UIViewController *)fromViewController withToViewController:(UIViewController *)toViewController { CGFloat radius = 0.0f; if (self.circleDelegate && [self.circleDelegate respondsToSelector:@selector(circleStartingRadius)]) { radius = [self.circleDelegate circleStartingRadius]; CGRect bounds = toViewController.view.bounds; self.maximumCircleScale = ((MAX(bounds.size.height, bounds.size.width) / (radius)) * 1.25); } else { CGRect bounds = fromViewController.view.bounds; CGFloat diameter = MIN(bounds.size.height, bounds.size.width); radius = diameter / 2; } return radius; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZCirclePushAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,387
```objective-c // // RZSegmentControlMoveFadeAnimatedTransitioning.h // RZTransitions // // Created by Alex Rouse on 11/5/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZAnimationControllerProtocol.h" @interface RZSegmentControlMoveFadeAnimationController : NSObject <RZAnimationControllerProtocol> @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZSegmentControlMoveFadeAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
340
```objective-c // // RZShrinkTransitioner.h // RZTransitions // // Created by Nick Donaldson on 10/11/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZAnimationControllerProtocol.h" @interface RZShrinkZoomAnimationController : NSObject <RZAnimationControllerProtocol> @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZShrinkZoomAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
336
```objective-c // // RZCardSlideAnimatedTransitioning.m // RZTransitions // // Created by Nick Donaldson on 11/19/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZCardSlideAnimationController.h" #define kRZSlideTransitionTime 0.35 #define kRZSlideScaleChangePct 0.33 @implementation RZCardSlideAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; - (id)init { self = [super init]; if (self) { _transitionTime = kRZSlideTransitionTime; _horizontalOrientation = TRUE; _containerBackgroundColor = [UIColor blackColor]; } return self; } - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; UIView *bgView = [[UIView alloc] initWithFrame:container.bounds]; bgView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; bgView.backgroundColor = self.containerBackgroundColor; [container insertSubview:bgView atIndex:0]; if (self.isPositiveAnimation) { [container insertSubview:toViewController.view belowSubview:fromViewController.view]; toViewController.view.transform = CGAffineTransformMakeScale(1.0 - kRZSlideScaleChangePct, 1.0 - kRZSlideScaleChangePct); toViewController.view.alpha = 0.1f; [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ toViewController.view.transform = CGAffineTransformIdentity; toViewController.view.alpha = 1.0f; if (self.horizontalOrientation) { fromViewController.view.transform = CGAffineTransformMakeTranslation(-container.bounds.size.width, 0); } else { fromViewController.view.transform = CGAffineTransformMakeTranslation(0, container.bounds.size.height); } } completion:^(BOOL finished) { toViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.transform = CGAffineTransformIdentity; [bgView removeFromSuperview]; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } else { [container addSubview:toViewController.view]; if (self.horizontalOrientation) { toViewController.view.transform = CGAffineTransformMakeTranslation(-container.bounds.size.width, 0); } else { toViewController.view.transform = CGAffineTransformMakeTranslation(0, container.bounds.size.height); } [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ toViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.transform = CGAffineTransformMakeScale(1.0 - kRZSlideScaleChangePct, 1.0 - kRZSlideScaleChangePct); fromViewController.view.alpha = 0.1f; } completion:^(BOOL finished) { toViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.alpha = 1.0f; [bgView removeFromSuperview]; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } } - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { return self.transitionTime; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZCardSlideAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,008
```objective-c // // RZZoomAlphaAnimationController.m // RZTransitions // // Created by Stephen Barnes on 2/12/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZZoomAlphaAnimationController.h" #define kRZZoomAlphaTransitionTime 0.3 #define kRZZoomAlphaMaxScale 1.333 @implementation RZZoomAlphaAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; #pragma mark - Animated transitioning - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; toViewController.view.userInteractionEnabled = YES; if (!self.isPositiveAnimation) { fromViewController.view.opaque = NO; [container insertSubview:toViewController.view belowSubview:fromViewController.view]; [UIView animateWithDuration:kRZZoomAlphaTransitionTime delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ fromViewController.view.alpha = 0.f; fromViewController.view.transform = CGAffineTransformMakeScale(kRZZoomAlphaMaxScale, kRZZoomAlphaMaxScale); } completion:^(BOOL finished) { fromViewController.view.alpha = 1.f; fromViewController.view.transform = CGAffineTransformIdentity; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } else { toViewController.view.opaque = NO; toViewController.view.alpha = 0.f; toViewController.view.transform = CGAffineTransformMakeScale(kRZZoomAlphaMaxScale, kRZZoomAlphaMaxScale); [container addSubview:toViewController.view]; [UIView animateWithDuration:kRZZoomAlphaTransitionTime delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ toViewController.view.alpha = 1.f; toViewController.view.transform = CGAffineTransformIdentity; } completion:^(BOOL finished) { toViewController.view.opaque = YES; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } } - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { return kRZZoomAlphaTransitionTime; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZZoomAlphaAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
761
```objective-c // // RZZoomPushAnimatedTransitioning.h // RZTransitions // // Created by Nick Donaldson on 10/22/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZAnimationControllerProtocol.h" @interface RZZoomPushAnimationController : NSObject <RZAnimationControllerProtocol> @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZZoomPushAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
336
```objective-c // // RZRectZoomAnimationController.m // RZTransitions // // Created by Stephen Barnes on 05/01/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZRectZoomAnimationController.h" static const CGFloat kRZRectZoomAnimationTime = 0.7f; static const CGFloat kRZRectZoomDefaultFadeAnimationTime = 0.2f; static const CGFloat kRZRectZoomDefaultSpringDampening = 0.6f; static const CGFloat kRZRectZoomDefaultSpringVelocity = 15.0f; @interface RZRectZoomAnimationController () @end @implementation RZRectZoomAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; #pragma mark - Animation Transition - (id)init { self = [super init]; if (self) { _shouldFadeBackgroundViewController = YES; _animationSpringDampening = kRZRectZoomDefaultSpringDampening; _animationSpringVelocity = kRZRectZoomDefaultSpringVelocity; } return self; } - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; __block CGRect originalFrame = toViewController.view.frame; __block CGRect cellFrame = CGRectZero; if ( (self.rectZoomDelegate != nil) && [self.rectZoomDelegate respondsToSelector:@selector(rectZoomPosition)] ) { cellFrame = [self.rectZoomDelegate rectZoomPosition]; } if ( self.isPositiveAnimation ) { UIView *resizableSnapshotView = [toViewController.view resizableSnapshotViewFromRect:toViewController.view.bounds afterScreenUpdates:YES withCapInsets:UIEdgeInsetsZero]; resizableSnapshotView.frame = cellFrame; [container addSubview:resizableSnapshotView]; [UIView animateWithDuration:kRZRectZoomDefaultFadeAnimationTime animations:^{ if (self.shouldFadeBackgroundViewController) { fromViewController.view.alpha = 0.0f; } }]; [UIView animateWithDuration:kRZRectZoomAnimationTime delay:0 usingSpringWithDamping:self.animationSpringDampening initialSpringVelocity:self.animationSpringVelocity options:UIViewAnimationOptionCurveEaseInOut animations:^{ resizableSnapshotView.frame = originalFrame; } completion:^(BOOL finished) { [container addSubview:toViewController.view]; [resizableSnapshotView removeFromSuperview]; if (self.shouldFadeBackgroundViewController) { fromViewController.view.alpha = 1.0f; } [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } else { UIView *resizableSnapshotView = [fromViewController.view resizableSnapshotViewFromRect:fromViewController.view.bounds afterScreenUpdates:YES withCapInsets:UIEdgeInsetsZero]; resizableSnapshotView.frame = fromViewController.view.frame; [container insertSubview:resizableSnapshotView aboveSubview:fromViewController.view]; [container insertSubview:toViewController.view belowSubview:resizableSnapshotView]; toViewController.view.alpha = 0.0f; [toViewController viewWillAppear:YES]; [UIView animateWithDuration:kRZRectZoomDefaultFadeAnimationTime animations:^{ toViewController.view.alpha = 1.0f; }]; [UIView animateWithDuration:kRZRectZoomAnimationTime delay:0 usingSpringWithDamping:self.animationSpringDampening initialSpringVelocity:self.animationSpringVelocity options:UIViewAnimationOptionCurveEaseInOut animations:^{ resizableSnapshotView.frame = cellFrame; } completion:^(BOOL finished) { [UIView animateWithDuration:kRZRectZoomDefaultFadeAnimationTime animations:^{ resizableSnapshotView.alpha = 0.0f; } completion:^(BOOL finished) { [resizableSnapshotView removeFromSuperview]; [container addSubview:fromViewController.view]; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; }]; } } - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { return kRZRectZoomAnimationTime; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZRectZoomAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,158
```objective-c // // RZAnimationControllerProtocol.h // RZTransitions // // Created by Stephen Barnes on 12/16/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #ifndef RZTransitions_RZAnimationControllerProtocol_h #define RZTransitions_RZAnimationControllerProtocol_h @protocol RZAnimationControllerProtocol <UIViewControllerAnimatedTransitioning> @required /** * If the animation should be positive or negative. * Positive: push / present / fromTop / toRight * Negative: pop / dismiss / fromBottom / toLeft */ @property (nonatomic, assign) BOOL isPositiveAnimation; @end #endif // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZAnimationControllerProtocol.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
393
```objective-c // // RZRectZoomAnimationController.h // RZTransitions // // Created by Stephen Barnes on 12/13/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZAnimationControllerProtocol.h" @protocol RZRectZoomAnimationDelegate <NSObject> // Return the rect to insert the next view into. This should be relative to the view controller's view. - (CGRect)rectZoomPosition; @end @interface RZRectZoomAnimationController : NSObject <RZAnimationControllerProtocol> @property (nonatomic, weak) id<RZRectZoomAnimationDelegate> rectZoomDelegate; @property (nonatomic, assign) BOOL shouldFadeBackgroundViewController; @property (nonatomic, assign) CGFloat animationSpringDampening; @property (nonatomic, assign) CGFloat animationSpringVelocity; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZRectZoomAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
435
```objective-c // // RZZoomBlurAnimatedTransitioning.m // RZTransitions // // Created by Nick Donaldson on 10/17/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZZoomBlurAnimationController.h" #import "UIImage+RZTransitionsFastImageBlur.h" #import <objc/runtime.h> #define kRZZBAnimationTransitionTime 0.3 #define kRZZBZoomScale 1.2 #define kRZZBDefaultBlurRadius 12.0f #define kRZZBDefaultSaturationDelta 1.0f #define kRZZBDefaultTintColor [UIColor colorWithWhite:1.0f alpha:0.15f] static char kRZZoomBlurImageAssocKey; @implementation RZZoomBlurAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; - (CGFloat)blurRadius { if (_blurRadius == 0) { _blurRadius = kRZZBDefaultBlurRadius; } return _blurRadius; } - (CGFloat)saturationDelta { if (_saturationDelta == 0) { _saturationDelta = kRZZBDefaultSaturationDelta; } return _saturationDelta; } - (UIColor *)blurTintColor { if (!_blurTintColor) { _blurTintColor = kRZZBDefaultTintColor; } return _blurTintColor; } #pragma mark - Animated transitioning - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; toViewController.view.userInteractionEnabled = YES; if (!self.isPositiveAnimation) { // This may not exist if we didn't present with this guy originally. If not, it will just do an alpha fade, no blur. UIImageView *blurImageView = objc_getAssociatedObject(fromViewController, &kRZZoomBlurImageAssocKey); fromViewController.view.backgroundColor = [UIColor clearColor]; fromViewController.view.opaque = NO; [container insertSubview:toViewController.view belowSubview:fromViewController.view]; if (blurImageView) { [container insertSubview:blurImageView aboveSubview:toViewController.view]; } [UIView animateWithDuration:kRZZBAnimationTransitionTime delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ blurImageView.alpha = 0.f; fromViewController.view.alpha = 0.f; fromViewController.view.transform = CGAffineTransformMakeScale(kRZZBZoomScale, kRZZBZoomScale); } completion:^(BOOL finished) { fromViewController.view.alpha = 1.f; fromViewController.view.transform = CGAffineTransformIdentity; [blurImageView removeFromSuperview]; objc_setAssociatedObject(fromViewController, &kRZZoomBlurImageAssocKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } else { UIImage *blurImage = [UIImage blurredImageByCapturingView:fromViewController.view withRadius:self.blurRadius tintColor:self.blurTintColor saturationDeltaFactor:self.saturationDelta]; UIImageView *blurImageView = [[UIImageView alloc] initWithImage:blurImage]; objc_setAssociatedObject(toViewController, &kRZZoomBlurImageAssocKey, blurImageView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); [container addSubview:blurImageView]; blurImageView.alpha = 0.f; UIColor *originalBGColor = [toViewController.view backgroundColor]; toViewController.view.frame = fromViewController.view.frame; toViewController.view.backgroundColor = [UIColor clearColor]; toViewController.view.opaque = NO; toViewController.view.alpha = 0.f; toViewController.view.transform = CGAffineTransformMakeScale(kRZZBZoomScale, kRZZBZoomScale); [container addSubview:toViewController.view]; [UIView animateWithDuration:kRZZBAnimationTransitionTime delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ blurImageView.alpha = 1.f; toViewController.view.alpha = 1.f; toViewController.view.transform = CGAffineTransformIdentity; } completion:^(BOOL finished) { toViewController.view.backgroundColor = originalBGColor; toViewController.view.opaque = YES; [toViewController.view insertSubview:blurImageView atIndex:0]; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } } - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { return kRZZBAnimationTransitionTime; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZZoomBlurAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,270
```objective-c // // RZTransitionsAnimationControllers.h // RZTransitions // // Created by Stephen Barnes on 3/13/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #ifndef RZTransitions_Demo_RZTransitionsAnimationControllers_h #define RZTransitions_Demo_RZTransitionsAnimationControllers_h #import "RZCardSlideAnimationController.h" #import "RZCirclePushAnimationController.h" #import "RZSegmentControlMoveFadeAnimationController.h" #import "RZShrinkZoomAnimationController.h" #import "RZZoomAlphaAnimationController.h" #import "RZZoomBlurAnimationController.h" #import "RZZoomPushAnimationController.h" #import "RZRectZoomAnimationController.h" #endif // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZTransitionsAnimationControllers.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
416
```objective-c // // RZZoomPushAnimatedTransitioning.m // RZTransitions // // Created by Nick Donaldson on 10/22/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZZoomPushAnimationController.h" #import "RZHorizontalInteractionController.h" #define kRZPushTransitionTime 0.35 #define kRZPushScaleChangePct 0.33 @implementation RZZoomPushAnimationController @synthesize isPositiveAnimation = _isPositiveAnimation; - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIView *container = [transitionContext containerView]; if (self.isPositiveAnimation) { [container insertSubview:toViewController.view belowSubview:fromViewController.view]; toViewController.view.transform = CGAffineTransformMakeScale(1.0 - kRZPushScaleChangePct, 1.0 - kRZPushScaleChangePct); [toViewController viewWillAppear:YES]; [UIView animateWithDuration:kRZPushTransitionTime delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ toViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.transform = CGAffineTransformMakeScale(1.0 + kRZPushScaleChangePct, 1.0 + kRZPushScaleChangePct); fromViewController.view.alpha = 0.0f; } completion:^(BOOL finished) { toViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.alpha = 1.0f; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } else { [container addSubview:toViewController.view]; toViewController.view.transform = CGAffineTransformMakeScale(1.0 + kRZPushScaleChangePct, 1.0 + kRZPushScaleChangePct); toViewController.view.alpha = 0.0f; [toViewController viewWillAppear:YES]; [UIView animateWithDuration:kRZPushTransitionTime delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ toViewController.view.transform = CGAffineTransformIdentity; toViewController.view.alpha = 1.0f; fromViewController.view.transform = CGAffineTransformMakeScale(1.0 - kRZPushScaleChangePct, 1.0 - kRZPushScaleChangePct); } completion:^(BOOL finished) { toViewController.view.transform = CGAffineTransformIdentity; fromViewController.view.transform = CGAffineTransformIdentity; toViewController.view.alpha = 1.0f; [transitionContext completeTransition:!transitionContext.transitionWasCancelled]; }]; } } - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext { return kRZPushTransitionTime; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZZoomPushAnimationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
894
```objective-c // // RZZoomBlurAnimatedTransitioning.h // RZTransitions // // Created by Nick Donaldson on 10/17/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZAnimationControllerProtocol.h" @interface RZZoomBlurAnimationController : NSObject <RZAnimationControllerProtocol> @property (nonatomic, assign) CGFloat blurRadius; @property (nonatomic, assign) CGFloat saturationDelta; @property (nonatomic, strong) UIColor* blurTintColor; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Transitions/RZZoomBlurAnimationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
367
```objective-c // // RZPinchInteration.h // RZTransitions // // Created by Stephen Barnes on 12/11/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZTransitionInteractionControllerProtocol.h" @interface RZPinchInteractionController : UIPercentDrivenInteractiveTransition <RZTransitionInteractionController, UIGestureRecognizerDelegate> @property(nonatomic, strong) UIViewController *fromViewController; @property(nonatomic, strong) UIPinchGestureRecognizer *gestureRecognizer; - (CGFloat)translationPercentageWithPinchGestureRecognizer:(UIPinchGestureRecognizer *)pinchGestureRecognizer; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZPinchInteractionController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
386
```objective-c // // RZHorizontalTransitionInteractor.m // RZTransitions // // Created by Stephen Barnes on 12/3/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZHorizontalInteractionController.h" #define kRZHorizontalTransitionCompletionPercentage 0.3f @implementation RZHorizontalInteractionController - (BOOL)isGesturePositive:(UIPanGestureRecognizer *)panGestureRecognizer { return [self translationWithPanGestureRecongizer:panGestureRecognizer] < 0; } - (CGFloat)swipeCompletionPercent { return kRZHorizontalTransitionCompletionPercentage; } - (CGFloat)translationPercentageWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer { return fabsf([self translationWithPanGestureRecongizer:panGestureRecognizer] / panGestureRecognizer.view.bounds.size.width); } - (CGFloat)translationWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer { return [panGestureRecognizer translationInView:panGestureRecognizer.view].x; } #pragma mark - UIGestureRecognizerDelegate - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { UIPanGestureRecognizer *panGestureRecognizer = (UIPanGestureRecognizer*)gestureRecognizer; CGFloat yTranslation = [panGestureRecognizer translationInView:panGestureRecognizer.view].y; return yTranslation == 0; } return YES; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZHorizontalInteractionController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
562
```objective-c // // RZTransitionInteractionControllerProtocol.h // RZTransitions // // Created by Stephen Barnes on 12/4/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZTransitionAction.h" #ifndef RZTransitions_RZTransitionInteractorProtocol_h #define RZTransitions_RZTransitionInteractorProtocol_h @protocol RZTransitionInteractionController; @protocol RZTransitionInteractionControllerDelegate; @protocol RZTransitionInteractionControllerDelegate <NSObject> @optional /** * Used to specify the next @c UIViewController that is shown when an interactor is ready to present, push, or move to a new tab. * * @param interactor The interactor that is requesting a new @c UIViewController. * * @return the @c UIViewController to be shown. */ - (UIViewController *)nextViewControllerForInteractor:(id<RZTransitionInteractionController>)interactor; @end @protocol RZTransitionInteractionController <UIViewControllerInteractiveTransitioning> @required /** * Is the transition interaction controller currently in a user interaction state. */ @property (nonatomic, assign, readwrite) BOOL isInteractive; /** * Should the transition interaction controller complete the transaction if it is released in its current state. Ex: a swipe interactor should not complete until it has passed a threshold percentage. */ @property (nonatomic, assign, readwrite) BOOL shouldCompleteTransition; /** * The bitmap of actions that a transition interaction controller will complete for. */ @property (nonatomic, assign, readwrite) RZTransitionAction action; /** * The delegate that allows the interaction controller to receive a @UIViewController to display for positive actions such as push and present. */ @property (nonatomic, weak) id<RZTransitionInteractionControllerDelegate> nextViewControllerDelegate; /** * Initialize the Interaction Controller in the supplied @c UIViewController. Typically adds a gesture recognizer to the @c UIViewController's view. * * @param viewController the @c UIViewController that has interactions to transition with. * @param action the bitmap of action the interaction controller should respond to. */ - (void)attachViewController:(UIViewController *)viewController withAction:(RZTransitionAction)action; @end #endif // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZTransitionInteractionControllerProtocol.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
711
```objective-c // // RZVerticalTransitionInteractor.h // RZTransitions // // Created by Stephen Barnes on 12/4/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZBaseSwipeInteractionController.h" @interface RZVerticalSwipeInteractionController : RZBaseSwipeInteractionController @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZVerticalSwipeInteractionController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
328
```objective-c // // RZOverscrollInteractionController.h // RZTransitions // // Created by Stephen Barnes on 12/16/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> #import "RZTransitionInteractionControllerProtocol.h" @interface RZOverscrollInteractionController : UIPercentDrivenInteractiveTransition <RZTransitionInteractionController, UIScrollViewDelegate> @property(nonatomic, strong) UIViewController *fromViewController; - (void)watchScrollView:(UIScrollView*)scrollView; - (CGFloat)completionPercent; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZOverscrollInteractionController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
371
```objective-c // // RZVerticalTransitionInteractor.m // RZTransitions // // Created by Stephen Barnes on 12/4/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZVerticalSwipeInteractionController.h" #define kRZVerticalTransitionCompletionPercentage 0.3f @implementation RZVerticalSwipeInteractionController - (BOOL)isGesturePositive:(UIPanGestureRecognizer *)panGestureRecognizer { return [self translationWithPanGestureRecongizer:panGestureRecognizer] < 0; } - (CGFloat)swipeCompletionPercent { return kRZVerticalTransitionCompletionPercentage; } - (CGFloat)translationPercentageWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer { return fabsf([self translationWithPanGestureRecongizer:panGestureRecognizer] / panGestureRecognizer.view.bounds.size.height); } - (CGFloat)translationWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer { return [panGestureRecognizer translationInView:panGestureRecognizer.view].y; } #pragma mark - UIGestureRecognizerDelegate - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { UIPanGestureRecognizer *panGestureRecognizer = (UIPanGestureRecognizer*)gestureRecognizer; CGFloat xTranslation = [panGestureRecognizer translationInView:panGestureRecognizer.view].x; return xTranslation == 0; } return YES; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZVerticalSwipeInteractionController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
564
```objective-c // // RZBaseSwipeInteractionController.h // RZTransitions // // Created by Stephen Barnes on 12/4/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> #import "RZTransitionInteractionControllerProtocol.h" @interface RZBaseSwipeInteractionController : UIPercentDrivenInteractiveTransition <RZTransitionInteractionController, UIGestureRecognizerDelegate> @property (nonatomic, strong) UIViewController *fromViewController; @property (nonatomic, strong) UIPanGestureRecognizer *gestureRecognizer; @property (nonatomic, assign) BOOL reverseGestureDirection; - (BOOL)isGesturePositive:(UIPanGestureRecognizer *)panGestureRecognizer; - (CGFloat)swipeCompletionPercent; - (CGFloat)translationPercentageWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer; - (CGFloat)translationWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZBaseSwipeInteractionController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
446
```objective-c // // RZTransitionsInteractionControllers.h // RZTransitions // // Created by Stephen Barnes on 3/13/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #ifndef RZTransitions_Demo_RZTransitionsInteractionControllers_h #define RZTransitions_Demo_RZTransitionsInteractionControllers_h #import "RZHorizontalInteractionController.h" #import "RZVerticalSwipeInteractionController.h" #import "RZOverscrollInteractionController.h" #import "RZPinchInteractionController.h" #endif // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZTransitionsInteractionControllers.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
372
```objective-c // // RZBaseSwipeInteractionTransition.m // RZTransitions // // Created by Stephen Barnes on 12/4/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZBaseSwipeInteractionController.h" #define kRZBaseSwipeInteractionDefaultCompletionPercentage 0.3f @implementation RZBaseSwipeInteractionController @synthesize action = _action; @synthesize isInteractive = _isInteractive; @synthesize nextViewControllerDelegate = _delegate; @synthesize shouldCompleteTransition = _shouldCompleteTransition; - (id)init { self = [super init]; if (self) { _reverseGestureDirection = NO; } return self; } - (void)attachViewController:(UIViewController *)viewController withAction:(RZTransitionAction)action { self.fromViewController = viewController; self.action = action; [self attachGestureRecognizerToView:self.fromViewController.view]; } - (void)attachGestureRecognizerToView:(UIView*)view { [view addGestureRecognizer:self.gestureRecognizer]; } -(void)dealloc { [self.gestureRecognizer.view removeGestureRecognizer:self.gestureRecognizer]; } - (CGFloat)completionSpeed { return 1 - self.percentComplete; } #pragma mark - UIPanGestureRecognizer Delegate - (void)handlePanGesture:(UIPanGestureRecognizer *)panGestureRecognizer { CGFloat percentage = [self translationPercentageWithPanGestureRecongizer:panGestureRecognizer]; BOOL positiveDirection = self.reverseGestureDirection ? ![self isGesturePositive:panGestureRecognizer] : [self isGesturePositive:panGestureRecognizer]; switch (panGestureRecognizer.state) { case UIGestureRecognizerStateBegan: self.isInteractive = YES; if (positiveDirection && self.nextViewControllerDelegate && [self.nextViewControllerDelegate conformsToProtocol:@protocol(RZTransitionInteractionControllerDelegate)]) { if (self.action & RZTransitionAction_Push) { [self.fromViewController.navigationController pushViewController:[self.nextViewControllerDelegate nextViewControllerForInteractor:self] animated:YES]; } else if (self.action & RZTransitionAction_Present) { // TODO: set and store a completion [self.fromViewController presentViewController:[self.nextViewControllerDelegate nextViewControllerForInteractor:self] animated:YES completion:nil]; } } else { if (self.action & RZTransitionAction_Pop) { [self.fromViewController.navigationController popViewControllerAnimated:YES]; } else if (self.action & RZTransitionAction_Dismiss) { [self.fromViewController dismissViewControllerAnimated:YES completion:nil]; } } break; case UIGestureRecognizerStateChanged: if (self.isInteractive) { self.shouldCompleteTransition = (percentage > [self swipeCompletionPercent]); [self updateInteractiveTransition:percentage]; } break; case UIGestureRecognizerStateCancelled: self.isInteractive = NO; [self cancelInteractiveTransition]; break; case UIGestureRecognizerStateEnded: if (self.isInteractive) { self.isInteractive = NO; if (!self.shouldCompleteTransition || panGestureRecognizer.state == UIGestureRecognizerStateCancelled) { [self cancelInteractiveTransition]; } else { [self finishInteractiveTransition]; } } default: break; } } - (BOOL)isGesturePositive:(UIPanGestureRecognizer *)panGestureRecognizer { [NSException raise:NSInternalInconsistencyException format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]; return NO; } - (CGFloat)swipeCompletionPercent { return kRZBaseSwipeInteractionDefaultCompletionPercentage; } - (CGFloat)translationPercentageWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer { [NSException raise:NSInternalInconsistencyException format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]; return 0.0f; } - (CGFloat)translationWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer { [NSException raise:NSInternalInconsistencyException format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]; return 0.0f; } #pragma mark - Overridden Properties - (UIGestureRecognizer*)gestureRecognizer { if (!_gestureRecognizer) { _gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)]; [_gestureRecognizer setDelegate:self]; } return _gestureRecognizer; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZBaseSwipeInteractionController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,190
```objective-c // // RZOverscrollInteractionController.m // RZTransitions // // Created by Stephen Barnes on 12/16/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZOverscrollInteractionController.h" #define kRZOverscrollInteractionDefaultCompletionPercentage 0.35f #define kRZOverscrollInteractionDefaultTopStartDistance 25.0f #define kRZOverscrollInteractionDefaultBottomStartDistance 25.0f #define kRZOverscrollInteractionDefaultTranslationDistance 200.0f @interface RZOverscrollInteractionController () @property (nonatomic, assign) CGFloat lastYOffset; @end @implementation RZOverscrollInteractionController @synthesize action = _action; @synthesize isInteractive = _isInteractive; @synthesize nextViewControllerDelegate = _delegate; @synthesize shouldCompleteTransition = _shouldCompleteTransition; #pragma mark - RZTransitionInteractor Protocol - (void)attachViewController:(UIViewController *)viewController withAction:(RZTransitionAction)action { self.fromViewController = viewController; self.action = action; } - (void)watchScrollView:(UIScrollView*)scrollView { [scrollView setDelegate:self]; } #pragma mark - UIPercentDrivenInteractiveTransition - (CGFloat)completionSpeed { return 1 - self.percentComplete; } #pragma mark - Interaction Logic - (CGFloat)completionPercent { return kRZOverscrollInteractionDefaultCompletionPercentage; } - (CGFloat)translationPercentageWithScrollView:(UIScrollView *)scrollView isScrollingDown:(BOOL)isScrollingDown { if (isScrollingDown) { return ((scrollView.contentOffset.y + kRZOverscrollInteractionDefaultTopStartDistance) / kRZOverscrollInteractionDefaultTranslationDistance) * -1; } else { return ((scrollView.contentOffset.y + scrollView.frame.size.height - scrollView.contentSize.height - kRZOverscrollInteractionDefaultBottomStartDistance) / kRZOverscrollInteractionDefaultTranslationDistance); } } - (BOOL)scrollViewPastStartLocationWithScrollView:(UIScrollView *)scrollview isScrollingDown:(BOOL)isScrollingDown { if (isScrollingDown) { return (scrollview.contentOffset.y < kRZOverscrollInteractionDefaultTopStartDistance); } else { return ((scrollview.contentOffset.y + scrollview.frame.size.height - scrollview.contentSize.height) > kRZOverscrollInteractionDefaultBottomStartDistance); } } - (void)updateInteractionWithPercentage:(CGFloat)percentage { self.shouldCompleteTransition = percentage > [self completionPercent]; [self updateInteractiveTransition:percentage]; } - (void)completeInteractionWithScrollView:(UIScrollView *)scrollView { if (self.isInteractive) { self.isInteractive = NO; if(self.shouldCompleteTransition) { [scrollView setDelegate:nil]; } self.shouldCompleteTransition ? [self finishInteractiveTransition] : [self cancelInteractiveTransition]; } } - (void)beginTransition { if (!self.isInteractive) { self.isInteractive = YES; if (self.action & RZTransitionAction_Push) { [self.fromViewController.navigationController pushViewController:[self.nextViewControllerDelegate nextViewControllerForInteractor:self] animated:YES]; } else if (self.action & RZTransitionAction_Present) { [self.fromViewController presentViewController:[self.nextViewControllerDelegate nextViewControllerForInteractor:self] animated:YES completion:nil]; } else if (self.action & RZTransitionAction_Pop) { [self.fromViewController.navigationController popViewControllerAnimated:YES]; } else if (self.action & RZTransitionAction_Dismiss) { [self.fromViewController dismissViewControllerAnimated:YES completion:nil]; } } } // TODO: break out into helper class or base class #pragma mark - RZTransition Action Helpers + (BOOL)actionIsPresentOrDismissWithAction:(NSUInteger)action { return ((action & RZTransitionAction_Present) || (action & RZTransitionAction_Dismiss)); } + (BOOL)actionIsPushOrPopWithAction:(NSUInteger)action { return ((action & RZTransitionAction_Push) || (action & RZTransitionAction_Pop)); } + (BOOL)actionIsPushOrPresentWithAction:(NSUInteger)action { return ((action & RZTransitionAction_Present) || (action & RZTransitionAction_Push)); } + (BOOL)actionIsDismissOrPopWithAction:(NSUInteger)action { return ((action & RZTransitionAction_Dismiss) || (action & RZTransitionAction_Pop)); } #pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { BOOL overScrollDown = scrollView.contentOffset.y < 0; BOOL overScrollUp = scrollView.contentOffset.y > (scrollView.contentSize.height - scrollView.frame.size.height); BOOL scrollViewPastStartLocation = [self scrollViewPastStartLocationWithScrollView:scrollView isScrollingDown:overScrollDown]; BOOL scrollingDirectionUp = scrollView.contentOffset.y - self.lastYOffset < 0; if (!scrollViewPastStartLocation) { return; } CGFloat percentage = [self translationPercentageWithScrollView:scrollView isScrollingDown:overScrollDown]; if (overScrollDown && [RZOverscrollInteractionController actionIsPushOrPresentWithAction:self.action]) { if (!self.isInteractive && scrollingDirectionUp && scrollViewPastStartLocation && !scrollView.isDecelerating) { [self beginTransition]; } else if (scrollViewPastStartLocation) { [self updateInteractionWithPercentage:percentage]; } } else if (overScrollUp && [RZOverscrollInteractionController actionIsDismissOrPopWithAction:self.action]) { if (!self.isInteractive && !scrollingDirectionUp && scrollViewPastStartLocation && !scrollView.isDecelerating) { [self beginTransition]; } else if (scrollViewPastStartLocation) { [self updateInteractionWithPercentage:percentage]; } } self.lastYOffset = scrollView.contentOffset.y; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { [self completeInteractionWithScrollView:scrollView]; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self completeInteractionWithScrollView:scrollView]; } - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { [self completeInteractionWithScrollView:scrollView]; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZOverscrollInteractionController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,640
```objective-c // // RZHorizontalTransitionInteractor.h // RZTransitions // // Created by Stephen Barnes on 12/3/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZBaseSwipeInteractionController.h" @interface RZHorizontalInteractionController : RZBaseSwipeInteractionController @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZHorizontalInteractionController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
334
```objective-c // // RZPinchInteration.m // RZTransitions // // Created by Stephen Barnes on 12/11/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZPinchInteractionController.h" #define kRZPinchInteractionDefaultCompletionPercentage 0.5f @implementation RZPinchInteractionController @synthesize action = _action; @synthesize isInteractive = _isInteractive; @synthesize nextViewControllerDelegate = _delegate; @synthesize shouldCompleteTransition = _shouldCompleteTransition; - (void)attachViewController:(UIViewController *)viewController withAction:(RZTransitionAction)action { self.fromViewController = viewController; self.action = action; [self attachGestureRecognizerToView:self.fromViewController.view]; } - (void)attachGestureRecognizerToView:(UIView*)view { [view addGestureRecognizer:self.gestureRecognizer]; } -(void)dealloc { [self.gestureRecognizer.view removeGestureRecognizer:self.gestureRecognizer]; } - (CGFloat)completionSpeed { return 1 - self.percentComplete; } - (CGFloat)translationPercentageWithPinchGestureRecognizer:(UIPinchGestureRecognizer *)pinchGestureRecognizer { return pinchGestureRecognizer.scale / 2.0f; } - (BOOL)isPinchWithGesture:(UIPinchGestureRecognizer *)pinchGestureRecognizer { return pinchGestureRecognizer.scale < 1.0f; } #pragma mark - UIPinchGestureRecognizer Delegate - (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinchGestureRecognizer { CGFloat percentage = [self translationPercentageWithPinchGestureRecognizer:pinchGestureRecognizer]; BOOL isPinch = [self isPinchWithGesture:pinchGestureRecognizer]; switch (pinchGestureRecognizer.state) { case UIGestureRecognizerStateBegan: self.isInteractive = YES; if (!isPinch && self.nextViewControllerDelegate && [self.nextViewControllerDelegate conformsToProtocol:@protocol(RZTransitionInteractionControllerDelegate)]) { if (self.action & RZTransitionAction_Push) { [self.fromViewController.navigationController pushViewController:[self.nextViewControllerDelegate nextViewControllerForInteractor:self] animated:YES]; } else if (self.action & RZTransitionAction_Present) { // TODO: set and store a completion [self.fromViewController presentViewController:[self.nextViewControllerDelegate nextViewControllerForInteractor:self] animated:YES completion:nil]; } } else { if (self.action & RZTransitionAction_Pop) { [self.fromViewController.navigationController popViewControllerAnimated:YES]; } else if (self.action & RZTransitionAction_Dismiss) { [self.fromViewController dismissViewControllerAnimated:YES completion:nil]; } } break; case UIGestureRecognizerStateChanged: if (self.isInteractive) { self.shouldCompleteTransition = (percentage > kRZPinchInteractionDefaultCompletionPercentage); [self updateInteractiveTransition:percentage]; } break; case UIGestureRecognizerStateCancelled: self.isInteractive = NO; [self cancelInteractiveTransition]; break; case UIGestureRecognizerStateEnded: if (self.isInteractive) { self.isInteractive = NO; if (!self.shouldCompleteTransition || pinchGestureRecognizer.state == UIGestureRecognizerStateCancelled) { [self cancelInteractiveTransition]; } else { [self finishInteractiveTransition]; } } default: break; } } #pragma mark - Overridden Properties - (UIGestureRecognizer*)gestureRecognizer { if (!_gestureRecognizer) { _gestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)]; [_gestureRecognizer setDelegate:self]; } return _gestureRecognizer; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Interactors/RZPinchInteractionController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,027
```objective-c // // RZTransitionsNavigationController.h // RZTransitions // // Created by Stephen Barnes on 3/7/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> @interface RZTransitionsNavigationController : UINavigationController @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Components/RZTransitionsNavigationController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
319
```objective-c // // RZTransitionsNavigationController.m // RZTransitions // // Created by Stephen Barnes on 3/7/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZTransitionsNavigationController.h" #import "RZTransitionsManager.h" @interface RZTransitionsNavigationController () <UIGestureRecognizerDelegate> @end @implementation RZTransitionsNavigationController - (void)viewDidLoad { [super viewDidLoad]; __weak RZTransitionsNavigationController *weakSelf = self; if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { [self.interactivePopGestureRecognizer setEnabled:YES]; self.interactivePopGestureRecognizer.delegate = weakSelf; self.delegate = [RZTransitionsManager shared]; } } // Hijack the push method to disable the gesture //- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated //{ // if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { // self.interactivePopGestureRecognizer.enabled = NO; // } // [super pushViewController:viewController animated:animated]; //} #pragma mark - UINavigationControllerDelegate // TODO: reenable the back gesture from the transitions manager //- (void)navigationController:(UINavigationController *)navigationController // didShowViewController:(UIViewController *)viewController // animated:(BOOL)animate //{ // // Enable the gesture again once the new controller is shown // if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { // self.interactivePopGestureRecognizer.enabled = YES; // } //} @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Components/RZTransitionsNavigationController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
579
```objective-c // // RZTransitionAction.h // RZTransitions // // Created by Stephen Barnes on 3/13/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #ifndef RZTransitions_Demo_RZTransitionAction_h #define RZTransitions_Demo_RZTransitionAction_h #define kRZTransitionActionCount 5 typedef NS_ENUM (NSInteger, RZTransitionAction) { RZTransitionAction_Push = (1 << 0), RZTransitionAction_Pop = (1 << 1), RZTransitionAction_Present = (1 << 2), RZTransitionAction_Dismiss = (1 << 3), RZTransitionAction_Tab = (1 << 4), RZTransitionAction_PushPop = RZTransitionAction_Push|RZTransitionAction_Pop, RZTransitionAction_PresentDismiss = RZTransitionAction_Present|RZTransitionAction_Dismiss, RZTransitionAction_Any = RZTransitionAction_Present|RZTransitionAction_Dismiss|RZTransitionAction_Tab, }; #endif // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Data/RZTransitionAction.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
498
```objective-c // // RZUniqueTransition.h // RZTransitions // // Created by Stephen Barnes on 3/13/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZTransitionAction.h" @interface RZUniqueTransition : NSObject <NSCopying> /** * The bitmask of possible actions allowed for this transition (push/pop/etc). */ @property (assign, nonatomic) RZTransitionAction transitionAction; /** * The class of the @c UIViewController being transitioned from. */ @property (assign, nonatomic) Class fromViewControllerClass; /** * The class of the @c UIViewController being transitioned to. */ @property (assign, nonatomic) Class toViewControllerClass; - (instancetype)initWithAction:(RZTransitionAction)action withFromViewControllerClass:(Class)fromViewController withToViewControllerClass:(Class)toViewController; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Data/RZUniqueTransition.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
446
```objective-c // // RZUniqueTransition.m // RZTransitions // // Created by Stephen Barnes on 3/13/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZUniqueTransition.h" @interface RZUniqueTransition () @end @implementation RZUniqueTransition #pragma mark - Equality overrides - (instancetype)initWithAction:(RZTransitionAction)action withFromViewControllerClass:(Class)fromViewController withToViewControllerClass:(Class)toViewController { self = [super init]; if (self) { _transitionAction = action; _fromViewControllerClass = fromViewController; _toViewControllerClass = toViewController; } return self; } - (id)copyWithZone:(NSZone *)zone { RZUniqueTransition *copiedObject = [[[self class] allocWithZone:zone] init]; copiedObject.transitionAction = self.transitionAction; copiedObject.toViewControllerClass = self.toViewControllerClass; copiedObject.fromViewControllerClass = self.fromViewControllerClass; return copiedObject; } - (NSUInteger)hash { return [[self fromViewControllerClass] hash] ^ [[self toViewControllerClass] hash] ^ [self transitionAction]; } - (BOOL)isEqual:(id)object { if (![object isKindOfClass:[RZUniqueTransition class]]) { return NO; } RZUniqueTransition *otherObject = (RZUniqueTransition *)object; return (otherObject.transitionAction & self.transitionAction) && (otherObject.fromViewControllerClass == self.fromViewControllerClass) && (otherObject.toViewControllerClass == self.toViewControllerClass); } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Data/RZUniqueTransition.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
610
```objective-c // // RZTransitionsManager.h // RZTransitions // // Created by Stephen Barnes on 3/12/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #import "RZTransitionAction.h" @protocol RZAnimationControllerProtocol; @protocol RZTransitionInteractionController; @class RZUniqueTransition; @interface RZTransitionsManager : NSObject < UINavigationControllerDelegate, UIViewControllerTransitioningDelegate, UITabBarControllerDelegate > /** * The default animation to use when pushing or popping a @c UIViewController on a @c UINavigationController. Uses nothing if nil. */ @property (strong, nonatomic) id<RZAnimationControllerProtocol> defaultPushPopAnimationController; /** * The default animation to use when presenting or dismissing a @c UIViewController on a @c UIViewController. Uses nothing if nil. */ @property (strong, nonatomic) id<RZAnimationControllerProtocol> defaultPresentDismissAnimationController; /** * The default animation to use when moving between tabs on a @c UITabBarController. Uses nothing if nil. */ @property (strong, nonatomic) id<RZAnimationControllerProtocol> defaultTabBarAnimationController; #pragma mark - Shared Instance + (RZTransitionsManager *)shared; #pragma mark - Public API Set Animations and Interactions /** * Set the animation to use when transitioning from one @c UIViewController class to any other @c UIViewController class. The @c RZTransitionAction is the set of actions that this animation will be used for. For example, if @c RZTransitionAction_Push is specified, the @c animationController specified will be used to animate from the @fromViewController to any other @UIViewController when pushing another view controller on top. * * @param animationController The animation to use when transitioning. * @param fromViewController The @c UIViewController class that is being transitioned from. * @param action The bitmask of possible actions to use the @c animationController. For example, specifying RZTransitionAction_Push|RZTransitionAction_Present will use this @c animationController for pushing and presenting from @c fromViewController. * * @return A unique key object that can be used to reference this animation pairing. */ - (RZUniqueTransition *)setAnimationController:(id<RZAnimationControllerProtocol>)animationController fromViewController:(Class)fromViewController forAction:(RZTransitionAction)action; /** * Set the animation to use when moving from one @c UIViewController class to another, specific @c UIViewController class. The @c RZTransitionAction is the set of actions that this animation will be used for. For example, if @c RZTransitionAction_Push is specified, the @c animationController specified will be used to animate from the @fromViewController to the @toViewController when pushing a @toViewController on top of a @fromViewController. * * @param animationController The animation to use when transitioning. * @param fromViewController The @c UIViewController class that is being transitioned from. * @param toViewController The @c UIViewController class that is being transitioned to. * @param action The bitmask of possible actions to use the @c animationController. For example, specifying RZTransitionAction_Push|RZTransitionAction_Present will use this @c animationController for pushing and presenting from @c fromViewController to @c toViewController. * * @return A unique key object that can be used to reference this animation pairing. */ - (RZUniqueTransition *)setAnimationController:(id<RZAnimationControllerProtocol>)animationController fromViewController:(Class)fromViewController toViewController:(Class)toViewController forAction:(RZTransitionAction)action; /** * Set the interactor to use when transitioning from one @c UIViewController class to another, specific @c UIViewController class. The @c RZTransitionAction is the set of actions that this animation will be used for. For example, if @c RZTransitionAction_Push is specified, the @c interactionController specified will be used to control the current animation controller if the current animation controller is animating from the @fromViewController to the @toViewController when pushing a @toViewController on top of a @fromViewController. * * @param interactionController The interaction controller to use when transitioning. * @param fromViewController The @c UIViewController class that is being transitioned from. * @param toViewController The @c UIViewController class that is being transitioned to. * @param action The bitmask of possible actions to use the @c interactionController. For example, specifying RZTransitionAction_Push|RZTransitionAction_Present will use this @c interactionController for pushing and presenting from @c fromViewController to @c toViewController. * * @return A unique key object that can be used to reference this interaction pairing. */ - (RZUniqueTransition *)setInteractionController:(id<RZTransitionInteractionController>)interactionController fromViewController:(Class)fromViewController toViewController:(Class)toViewController forAction:(RZTransitionAction)action; /** * Override the automatic transition direction (positive/negative) for a specific animation / view controller pairing. * * @param override Override if @c YES, ignore if @c NO. * @param transitionKey The unique key for the animation / view controller pairing to override. */ - (void)overrideAnimationDirection:(BOOL)override withTransition:(RZUniqueTransition *)transitionKey; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Managers/RZTransitionsManager.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,418
```objective-c // Created by Nick Donaldson, 2013 // // Faster version of Apple's blurred image category. // Since this is a modified version, I don't think the license is 100% // necessary, but here it is. // // (See line: ..if you redistribute the Apple Software in its entirety and // WITHOUT MODIFICATIONS, you must retain this notice and the following // text and disclaimers in all such redistributions of the Apple Software.) /* Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 Session. Please refer to the applicable WWDC 2013 Session for further information. IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EA1002 5/3/2013 */ @import UIKit; @interface UIImage (RZTransitionsFastImageBlur) // tint color ONLY APPLIES when blurring radius is non-negligible + (UIImage *)blurredImageByCapturingView:(UIView*)view withRadius:(CGFloat)blurRadius tintColor:(UIColor*)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor; + (UIImage *)blurredImageByCapturingView:(UIView *)view withRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor afterScreenUpdates:(BOOL)screenUpdates; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Utilities/UIImage+RZTransitionsFastImageBlur.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,223
```objective-c // // RZTransitionsManager.m // RZTransitions // // Created by Stephen Barnes on 3/12/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "RZTransitionsManager.h" #import "RZAnimationControllerProtocol.h" #import "RZUniqueTransition.h" #import "RZTransitionInteractionControllerProtocol.h" static NSString* const kRZTTransitionsAnyViewControllerKey = @"kRZTTransitionsAnyViewControllerKey"; static NSString* const kRZTTransitionsKeySpacer = @"_"; @interface RZTransitionsManager () @property (strong, nonatomic) NSMutableDictionary *animationControllers; @property (strong, nonatomic) NSMutableDictionary *animationControllerDirectionOverrides; @property (strong, nonatomic) NSMutableDictionary *interactionControllers; @end @implementation RZTransitionsManager + (RZTransitionsManager *)shared { static RZTransitionsManager *_defaultManager = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _defaultManager = [[[self class] alloc] init]; }); return _defaultManager; } - (id)init { self = [super init]; if (self) { self.animationControllers = [[NSMutableDictionary alloc] init]; self.animationControllerDirectionOverrides = [[NSMutableDictionary alloc] init]; self.interactionControllers = [[NSMutableDictionary alloc] init]; } return self; } #pragma mark - Public API Set Animations and Interactions - (RZUniqueTransition *)setAnimationController:(id<RZAnimationControllerProtocol>)animationController fromViewController:(Class)fromViewController forAction:(RZTransitionAction)action { return [self setAnimationController:animationController fromViewController:fromViewController toViewController:nil forAction:action]; } - (RZUniqueTransition *)setAnimationController:(id<RZAnimationControllerProtocol>)animationController fromViewController:(Class)fromViewController toViewController:(Class)toViewController forAction:(RZTransitionAction)action { RZUniqueTransition *keyValue = nil; for (NSUInteger x = 1; (x < (1 << (kRZTransitionActionCount - 1))); ) { if (action & x) { if ( ((x & RZTransitionAction_Pop) && !(x & RZTransitionAction_Push)) || ((x & RZTransitionAction_Dismiss) && !(x &RZTransitionAction_Present)) ) { keyValue = [[RZUniqueTransition alloc] initWithAction:x withFromViewControllerClass:toViewController withToViewControllerClass:fromViewController]; } else { keyValue = [[RZUniqueTransition alloc] initWithAction:x withFromViewControllerClass:fromViewController withToViewControllerClass:toViewController]; } [self.animationControllers setObject:animationController forKey:keyValue]; } x = x << 1; } return keyValue; } - (RZUniqueTransition *)setInteractionController:(id<RZTransitionInteractionController>)interactionController fromViewController:(Class)fromViewController toViewController:(Class)toViewController forAction:(RZTransitionAction)action { RZUniqueTransition *keyValue = nil; for (NSUInteger x = 1; (x < (1 << (kRZTransitionActionCount - 1))); ) { if (action & x) { RZUniqueTransition *keyValue = nil; if ( ((x & RZTransitionAction_Pop) && !(x & RZTransitionAction_Push)) || ((x & RZTransitionAction_Dismiss) && !(x &RZTransitionAction_Present)) ) { keyValue = [[RZUniqueTransition alloc] initWithAction:x withFromViewControllerClass:toViewController withToViewControllerClass:fromViewController]; } else { keyValue = [[RZUniqueTransition alloc] initWithAction:x withFromViewControllerClass:fromViewController withToViewControllerClass:toViewController]; } [self.interactionControllers setObject:interactionController forKey:keyValue]; } x = x << 1; } return keyValue; } - (void)overrideAnimationDirection:(BOOL)override withTransition:(RZUniqueTransition *)transitionKey { [self.animationControllerDirectionOverrides setObject:[NSNumber numberWithBool:override] forKey:transitionKey]; } #pragma mark - UIViewControllerTransitioningDelegate - (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source { RZUniqueTransition *keyValue = [[RZUniqueTransition alloc] initWithAction:RZTransitionAction_Present withFromViewControllerClass:[source class] withToViewControllerClass:[presented class]]; id<RZAnimationControllerProtocol> animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; if ( animationController == nil ) { keyValue.toViewControllerClass = nil; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; } if ( animationController == nil ) { animationController = self.defaultPresentDismissAnimationController; } if ( (animationController != nil) && (![[self.animationControllerDirectionOverrides objectForKey:keyValue] boolValue]) ) { animationController.isPositiveAnimation = YES; } return animationController; } - (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed { RZUniqueTransition *keyValue = [[RZUniqueTransition alloc] initWithAction:RZTransitionAction_Dismiss withFromViewControllerClass:[dismissed class] withToViewControllerClass:nil]; id<RZAnimationControllerProtocol> animationController = nil; // Find the dismissed view controller's view controller it is returning to UIViewController *presentingViewController = dismissed.presentingViewController; if ( [presentingViewController isKindOfClass:[UINavigationController class]] ) { UIViewController *childVC = (UIViewController *)[[presentingViewController childViewControllers] lastObject]; if ( childVC != nil ) { keyValue.toViewControllerClass = [childVC class]; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; if ( animationController == nil ) { keyValue.toViewControllerClass = nil; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; } if ( animationController == nil ) { keyValue.toViewControllerClass = [childVC class]; keyValue.fromViewControllerClass = nil; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; } } } if ( animationController == nil ) { keyValue.toViewControllerClass = nil; keyValue.fromViewControllerClass = [dismissed class]; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; // TODO: Check if from vc class is a navigation controller as well... } if ( animationController == nil ) { animationController = self.defaultPresentDismissAnimationController; } if ( (animationController != nil) && (![[self.animationControllerDirectionOverrides objectForKey:keyValue] boolValue]) ) { animationController.isPositiveAnimation = NO; } return animationController; } - (id <UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id <UIViewControllerAnimatedTransitioning>)animator { // Find the animator in the animationcontrollers list // Get **ITS** from and to VC information! __block id returnInteraction = nil; [self.animationControllers enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { id<RZAnimationControllerProtocol> animationController = (id<RZAnimationControllerProtocol>)obj; RZUniqueTransition *keyValue = (RZUniqueTransition *)key; if ( animator == animationController && keyValue.transitionAction & RZTransitionAction_Present ) { id<RZTransitionInteractionController> interactionController = (id<RZTransitionInteractionController>)[self.interactionControllers objectForKey:keyValue]; if (interactionController == nil) { keyValue.toViewControllerClass = nil; interactionController = (id<RZTransitionInteractionController>)[self.interactionControllers objectForKey:keyValue]; } if( (interactionController != nil) && (interactionController.isInteractive)) { returnInteraction = interactionController; *stop = YES; } } }]; return returnInteraction; } - (id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator { __block id returnInteraction = nil; [self.animationControllers enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { id<RZAnimationControllerProtocol> animationController = (id<RZAnimationControllerProtocol>)obj; RZUniqueTransition *keyValue = (RZUniqueTransition *)key; if ( animator == animationController && keyValue.transitionAction & RZTransitionAction_Dismiss ) { id<RZTransitionInteractionController> interactionController = (id<RZTransitionInteractionController>)[self.interactionControllers objectForKey:keyValue]; if (interactionController == nil) { keyValue.fromViewControllerClass = nil; interactionController = (id<RZTransitionInteractionController>)[self.interactionControllers objectForKey:keyValue]; } if( (interactionController != nil) && (interactionController.isInteractive)) { returnInteraction = interactionController; *stop = YES; } } }]; return returnInteraction; } #pragma mark - UINavigationControllerDelegate - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { } - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { } - (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController { return [self interactionControllerForAction:RZTransitionAction_PushPop withAnimationController:animationController]; } - (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { RZUniqueTransition *keyValue = [[RZUniqueTransition alloc] initWithAction:(operation == UINavigationControllerOperationPush) ? RZTransitionAction_Push : RZTransitionAction_Pop withFromViewControllerClass:[fromVC class] withToViewControllerClass:[toVC class]]; id<RZAnimationControllerProtocol> animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; if (animationController == nil) { keyValue.toViewControllerClass = nil; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; } if (animationController == nil) { keyValue.toViewControllerClass = [toVC class]; keyValue.fromViewControllerClass = nil; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; } if (animationController == nil) { animationController = self.defaultPushPopAnimationController; } if ( ![[self.animationControllerDirectionOverrides objectForKey:keyValue] boolValue] ) { if (operation == UINavigationControllerOperationPush) { animationController.isPositiveAnimation = YES; } else if (operation == UINavigationControllerOperationPop) { animationController.isPositiveAnimation = NO; } } return animationController; } #pragma mark - UIInteractionController Caching - (id <UIViewControllerInteractiveTransitioning>)interactionControllerForAction:(RZTransitionAction)action withAnimationController:(id <UIViewControllerAnimatedTransitioning>)animationController { for (RZUniqueTransition *key in self.interactionControllers) { id<RZTransitionInteractionController> interactionController = [self.interactionControllers objectForKey:key]; if ((interactionController.action & action) && [interactionController isInteractive]) { return interactionController; } } return nil; } #pragma mark - UITabBarControllerDelegate - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { } - (id <UIViewControllerInteractiveTransitioning>)tabBarController:(UITabBarController *)tabBarController interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>)animationController { return [self interactionControllerForAction:RZTransitionAction_Tab withAnimationController:animationController]; } - (id <UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { RZUniqueTransition *keyValue = [[RZUniqueTransition alloc] initWithAction:RZTransitionAction_Tab withFromViewControllerClass:[fromVC class] withToViewControllerClass:[toVC class]]; id<RZAnimationControllerProtocol> animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; if ( animationController == nil ) { keyValue.toViewControllerClass = nil; animationController = (id<RZAnimationControllerProtocol>)[self.animationControllers objectForKey:keyValue]; } if ( animationController == nil ) { animationController = self.defaultTabBarAnimationController; } NSUInteger fromVCIndex = [tabBarController.viewControllers indexOfObject:fromVC]; NSUInteger toVCIndex = [tabBarController.viewControllers indexOfObject:toVC]; if ( animationController && (![[self.animationControllerDirectionOverrides objectForKey:keyValue] boolValue]) ) { animationController.isPositiveAnimation = (fromVCIndex > toVCIndex); } return animationController; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Managers/RZTransitionsManager.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
3,168
```objective-c // // UIImage+RZTransitionsSnapshotHelpers.h // RZTransitions // // Created by Stephen Barnes on 4/30/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> @interface UIImage (RZTransitionsSnapshotHelpers) + (UIImage *)imageByCapturingView:(UIView*)view afterScreenUpdate:(BOOL)waitForUpdate; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Utilities/UIImage+RZTransitionsSnapshotHelpers.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
571
```objective-c /* Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 Session. Please refer to the applicable WWDC 2013 Session for further information. IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EA1002 5/3/2013 */ #import "UIImage+RZTransitionsFastImageBlur.h" @import Accelerate; #import <float.h> @implementation UIImage (ImageEffects) + (UIImage *)blurredImageByCapturingView:(UIView *)view withRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor { return [self blurredImageByCapturingView:view withRadius:blurRadius tintColor:tintColor saturationDeltaFactor:saturationDeltaFactor afterScreenUpdates:YES]; } + (UIImage *)blurredImageByCapturingView:(UIView *)view withRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor afterScreenUpdates:(BOOL)screenUpdates { UIImage *outputImage = nil; CGRect imageRect = { CGPointZero, view.bounds.size }; UIGraphicsBeginImageContextWithOptions(imageRect.size, NO, [UIScreen mainScreen].scale); [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:screenUpdates]; BOOL hasBlur = blurRadius > __FLT_EPSILON__; BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__; if (hasBlur || hasSaturationChange) { CGContextRef effectInContext = UIGraphicsGetCurrentContext(); vImage_Buffer effectInBuffer; effectInBuffer.data = CGBitmapContextGetData(effectInContext); effectInBuffer.width = CGBitmapContextGetWidth(effectInContext); effectInBuffer.height = CGBitmapContextGetHeight(effectInContext); effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext); UIGraphicsBeginImageContextWithOptions(imageRect.size, NO, [[UIScreen mainScreen] scale]); CGContextRef effectOutContext = UIGraphicsGetCurrentContext(); vImage_Buffer effectOutBuffer; effectOutBuffer.data = CGBitmapContextGetData(effectOutContext); effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext); effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext); effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext); if (hasBlur) { // A description of how to compute the box kernel width from the Gaussian // radius (aka standard deviation) appears in the SVG spec: // path_to_url#feGaussianBlurElement // // For larger values of 's' (s >= 2.0), an approximation can be used: Three // successive box-blurs build a piece-wise quadratic convolution kernel, which // approximates the Gaussian kernel to within roughly 3%. // // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) // // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel. // CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale]; NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5); if (radius % 2 != 1) { radius += 1; // force radius to be odd so that the three box-blur methodology works. } vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend); vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend); vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend); } BOOL effectImageBuffersAreSwapped = NO; if (hasSaturationChange) { CGFloat s = saturationDeltaFactor; CGFloat floatingPointSaturationMatrix[] = { 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0, 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0, 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0, 0, 0, 0, 1, }; const int32_t divisor = 256; NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]); int16_t saturationMatrix[matrixSize]; for (NSUInteger i = 0; i < matrixSize; ++i) { saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor); } if (hasBlur) { vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); effectImageBuffersAreSwapped = YES; } else { vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); } } if (!effectImageBuffersAreSwapped) { // Add in color tint. if (tintColor) { CGContextSaveGState(effectOutContext); CGContextSetFillColorWithColor(effectOutContext, tintColor.CGColor); CGContextFillRect(effectOutContext, imageRect); CGContextRestoreGState(effectOutContext); } outputImage = UIGraphicsGetImageFromCurrentImageContext(); } UIGraphicsEndImageContext(); if (effectImageBuffersAreSwapped) { // Add in color tint. if (tintColor) { CGContextSaveGState(effectInContext); CGContextSetFillColorWithColor(effectInContext, tintColor.CGColor); CGContextFillRect(effectInContext, imageRect); CGContextRestoreGState(effectInContext); } outputImage = UIGraphicsGetImageFromCurrentImageContext(); } } else { outputImage = UIGraphicsGetImageFromCurrentImageContext(); } UIGraphicsEndImageContext(); return outputImage; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Utilities/UIImage+RZTransitionsFastImageBlur.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
2,435
```objective-c // // UIColor+Random.m // RZTransitions // // Created by Stephen Barnes on 12/16/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "UIColor+Random.h" @implementation UIColor (Random) + (UIColor *)randomColor { CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0 CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1]; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/Utilities/UIColor+Random.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
454
```objective-c // // UIImage+RZTransitionsSnapshotHelpers.m // RZTransitions // // Created by Stephen Barnes on 4/30/14. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import "UIImage+RZTransitionsSnapshotHelpers.h" @implementation UIImage (RZTransitionsSnapshotHelpers) + (UIImage *)imageByCapturingView:(UIView*)view afterScreenUpdate:(BOOL)waitForUpdate { UIImage *outputImage = nil; CGRect imageRect = CGRectMake(0, 0, CGRectGetWidth(view.bounds), CGRectGetHeight(view.bounds)); UIGraphicsBeginImageContextWithOptions(imageRect.size, NO, 0.0); BOOL success = [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:waitForUpdate]; if ( success ) { outputImage = UIGraphicsGetImageFromCurrentImageContext(); } UIGraphicsEndImageContext(); return outputImage; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/RZTransitions/Utilities/UIImage+RZTransitionsSnapshotHelpers.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
677
```objective-c // // UIColor+Random.h // RZTransitions // // Created by Stephen Barnes on 12/16/13. // path_to_url // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #import <UIKit/UIKit.h> @interface UIColor (Random) + (UIColor *)randomColor; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/RZTransitions/Utilities/UIColor+Random.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
318
```objective-c // // CardView.m // YSLDraggingCardContainerDemo // // Created by yamaguchi on 2015/11/09. // #import "CardView.h" @implementation CardView - (instancetype)init { self = [super init]; if (self) { [self setup]; } return self; } - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setup]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { [self setup]; } return self; } - (void)setup { _imageView = [[UIImageView alloc]init]; _imageView.backgroundColor = [UIColor orangeColor]; _imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height * 0.8); [self addSubview:_imageView]; UIBezierPath *maskPath; maskPath = [UIBezierPath bezierPathWithRoundedRect:_imageView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(7.0, 7.0)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = _imageView.bounds; maskLayer.path = maskPath.CGPath; _imageView.layer.mask = maskLayer; _selectedView = [[UIView alloc]init]; _selectedView.frame = _imageView.frame; _selectedView.backgroundColor = [UIColor clearColor]; _selectedView.alpha = 0.0; [_imageView addSubview:_selectedView]; _label = [[UILabel alloc]init]; _label.backgroundColor = [UIColor clearColor]; _label.frame = CGRectMake(10, self.frame.size.height * 0.8, self.frame.size.width - 20, self.frame.size.height * 0.2); _label.font = [UIFont fontWithName:@"Futura-Medium" size:14]; [self addSubview:_label]; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/CardView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
475
```objective-c // // CardView.h // YSLDraggingCardContainerDemo // // Created by yamaguchi on 2015/11/09. // #import <UIKit/UIKit.h> #import "YSLCardView.h" @interface CardView : YSLCardView @property (nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UILabel *label; @property (nonatomic, strong) UIView *selectedView; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/CardView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
113
```objective-c // // YSLCardView.h // Crew-iOS // // Created by yamaguchi on 2015/10/23. // #import <UIKit/UIKit.h> @interface YSLCardView : UIView /** * Override */ - (void)setupCardView; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/YSLCardView.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
86
```objective-c // // YSLDraggableCardContainer.h // Crew-iOS // // Created by yamaguchi on 2015/10/22. // #import <UIKit/UIKit.h> @class YSLDraggableCardContainer; typedef NS_OPTIONS(NSInteger, YSLDraggableDirection) { YSLDraggableDirectionDefault = 0, // 0 YSLDraggableDirectionLeft = 1 << 0, // 1 YSLDraggableDirectionRight = 1 << 1, // 2 YSLDraggableDirectionUp = 1 << 2, // 4 YSLDraggableDirectionDown = 1 << 3 // 8 }; @protocol YSLDraggableCardContainerDataSource <NSObject> - (UIView *)cardContainerViewNextViewWithIndex:(NSInteger)index; - (NSInteger)cardContainerViewNumberOfViewInIndex:(NSInteger)index; @end @protocol YSLDraggableCardContainerDelegate <NSObject> - (void)cardContainerView:(YSLDraggableCardContainer *)cardContainerView didEndDraggingAtIndex:(NSInteger)index draggableView:(UIView *)draggableView draggableDirection:(YSLDraggableDirection)draggableDirection; @optional - (void)cardContainerViewDidCompleteAll:(YSLDraggableCardContainer *)container; - (void)cardContainerView:(YSLDraggableCardContainer *)cardContainerView didSelectAtIndex:(NSInteger)index draggableView:(UIView *)draggableView; - (void)cardContainderView:(YSLDraggableCardContainer *)cardContainderView updatePositionWithDraggableView:(UIView *)draggableView draggableDirection:(YSLDraggableDirection)draggableDirection widthRatio:(CGFloat)widthRatio heightRatio:(CGFloat)heightRatio; @end @interface YSLDraggableCardContainer : UIView /** * default is YSLDraggableDirectionLeft | YSLDraggableDirectionRight */ @property (nonatomic, assign) YSLDraggableDirection canDraggableDirection; @property (nonatomic, weak) id <YSLDraggableCardContainerDataSource> dataSource; @property (nonatomic, weak) id <YSLDraggableCardContainerDelegate> delegate; /** * reloads everything from scratch. redisplays card. */ - (void)reloadCardContainer; - (void)movePositionWithDirection:(YSLDraggableDirection)direction isAutomatic:(BOOL)isAutomatic; - (void)movePositionWithDirection:(YSLDraggableDirection)direction isAutomatic:(BOOL)isAutomatic undoHandler:(void (^)())undoHandler; - (UIView *)getCurrentView; @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/YSLDraggableCardContainer.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
579
```objective-c // // YFDraggableCardViewController.m // BigShow1949 // // Created by zhht01 on 16/3/18. // #import "YFDraggableCardViewController.h" #import "YSLDraggableCardContainer.h" #import "CardView.h" #define RGB(r, g, b) [UIColor colorWithRed: (r) / 255.0 green: (g) / 255.0 blue: (b) / 255.0 alpha : 1] @interface YFDraggableCardViewController () <YSLDraggableCardContainerDelegate, YSLDraggableCardContainerDataSource> @property (nonatomic, strong) YSLDraggableCardContainer *container; @property (nonatomic, strong) NSMutableArray *datas; @end @implementation YFDraggableCardViewController - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = RGB(235, 235, 235); // _container _container = [[YSLDraggableCardContainer alloc]init]; _container.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); _container.backgroundColor = [UIColor clearColor]; _container.dataSource = self; _container.delegate = self; _container.canDraggableDirection = YSLDraggableDirectionLeft | YSLDraggableDirectionRight | YSLDraggableDirectionUp; [self.view addSubview:_container]; // for (int i = 0; i < 4; i++) { UIView *view = [[UIView alloc]init]; CGFloat size = self.view.frame.size.width / 4; view.frame = CGRectMake(size * i, self.view.frame.size.height - 150, size, size); view.backgroundColor = [UIColor darkGrayColor]; [self.view addSubview:view]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(10, 10, size - 20, size - 20); [button setBackgroundColor:RGB(66, 172, 225)]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; button.titleLabel.font = [UIFont fontWithName:@"Futura-Medium" size:18]; button.clipsToBounds = YES; button.layer.cornerRadius = button.frame.size.width / 2; button.tag = i; [button addTarget:self action:@selector(buttonTap:) forControlEvents:UIControlEventTouchUpInside]; [view addSubview:button]; if (i == 0) { [button setTitle:@"Up" forState:UIControlStateNormal]; } if (i == 1) { [button setTitle:@"Down" forState:UIControlStateNormal]; } if (i == 2) { [button setTitle:@"Left" forState:UIControlStateNormal]; } if (i == 3) { [button setTitle:@"Right" forState:UIControlStateNormal]; } } // [self loadData]; // _container [_container reloadCardContainer]; } - (void)loadData { _datas = [NSMutableArray array]; for (int i = 0; i < 7; i++) { NSDictionary *dict = @{@"image" : [NSString stringWithFormat:@"photo_sample_0%d",i + 1], @"name" : @"YSLDraggableCardContainer Demo"}; [_datas addObject:dict]; } } #pragma mark -- Selector - (void)buttonTap:(UIButton *)button { if (button.tag == 0) { [_container movePositionWithDirection:YSLDraggableDirectionUp isAutomatic:YES]; } if (button.tag == 1) { __weak YFDraggableCardViewController *weakself = self; [_container movePositionWithDirection:YSLDraggableDirectionDown isAutomatic:YES undoHandler:^{ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"Do you want to reset?" preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [weakself.container movePositionWithDirection:YSLDraggableDirectionDown isAutomatic:YES]; }]]; [alertController addAction:[UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { [weakself.container movePositionWithDirection:YSLDraggableDirectionDefault isAutomatic:YES]; }]]; [self presentViewController:alertController animated:YES completion:nil]; }]; } if (button.tag == 2) { [_container movePositionWithDirection:YSLDraggableDirectionLeft isAutomatic:YES]; } if (button.tag == 3) { [_container movePositionWithDirection:YSLDraggableDirectionRight isAutomatic:YES]; } } #pragma mark -- YSLDraggableCardContainer DataSource // indexview - (UIView *)cardContainerViewNextViewWithIndex:(NSInteger)index { NSDictionary *dict = _datas[index]; CardView *view = [[CardView alloc]initWithFrame:CGRectMake(10, 64, self.view.frame.size.width - 20, self.view.frame.size.width - 20)]; view.backgroundColor = [UIColor whiteColor]; view.imageView.image = [UIImage imageNamed:dict[@"image"]]; view.label.text = [NSString stringWithFormat:@"%@ %ld",dict[@"name"],(long)index]; return view; } // view - (NSInteger)cardContainerViewNumberOfViewInIndex:(NSInteger)index { return _datas.count; } #pragma mark -- YSLDraggableCardContainer Delegate // view - (void)cardContainerView:(YSLDraggableCardContainer *)cardContainerView didEndDraggingAtIndex:(NSInteger)index draggableView:(UIView *)draggableView draggableDirection:(YSLDraggableDirection)draggableDirection { if (draggableDirection == YSLDraggableDirectionLeft) { [cardContainerView movePositionWithDirection:draggableDirection isAutomatic:NO]; } if (draggableDirection == YSLDraggableDirectionRight) { [cardContainerView movePositionWithDirection:draggableDirection isAutomatic:NO]; } if (draggableDirection == YSLDraggableDirectionUp) { [cardContainerView movePositionWithDirection:draggableDirection isAutomatic:NO]; } if (draggableDirection == YSLDraggableDirectionDown) { [cardContainerView movePositionWithDirection:draggableDirection isAutomatic:NO]; } } // view, - (void)cardContainderView:(YSLDraggableCardContainer *)cardContainderView updatePositionWithDraggableView:(UIView *)draggableView draggableDirection:(YSLDraggableDirection)draggableDirection widthRatio:(CGFloat)widthRatio heightRatio:(CGFloat)heightRatio { CardView *view = (CardView *)draggableView; if (draggableDirection == YSLDraggableDirectionDefault) { view.selectedView.alpha = 0; } if (draggableDirection == YSLDraggableDirectionLeft) { view.selectedView.backgroundColor = RGB(215, 104, 91); view.selectedView.alpha = widthRatio > 0.8 ? 0.8 : widthRatio; } if (draggableDirection == YSLDraggableDirectionRight) { view.selectedView.backgroundColor = RGB(114, 209, 142); view.selectedView.alpha = widthRatio > 0.8 ? 0.8 : widthRatio; } if (draggableDirection == YSLDraggableDirectionUp) { view.selectedView.backgroundColor = RGB(66, 172, 225); view.selectedView.alpha = heightRatio > 0.8 ? 0.8 : heightRatio; } } // - (void)cardContainerViewDidCompleteAll:(YSLDraggableCardContainer *)container; { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [container reloadCardContainer]; }); } // view - (void)cardContainerView:(YSLDraggableCardContainer *)cardContainerView didSelectAtIndex:(NSInteger)index draggableView:(UIView *)draggableView { NSLog(@"++ index : %ld",(long)index); } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/YFDraggableCardViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
1,743
```objective-c // // YFDraggableCardViewController.h // BigShow1949 // // Created by zhht01 on 16/3/18. // #import <UIKit/UIKit.h> @interface YFDraggableCardViewController : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/YFDraggableCardViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
54
```objective-c // // YSLCardView.m // Crew-iOS // // Created by yamaguchi on 2015/10/23. // #import "YSLCardView.h" @implementation YSLCardView - (instancetype)init { self = [super init]; if (self) { [self setupCardView]; } return self; } - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setupCardView]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { [self setupCardView]; } return self; } - (void)setupCardView { // Shadow // self.layer.shadowColor = [UIColor blackColor].CGColor; // self.layer.shadowOpacity = 0.33; // self.layer.shadowOffset = CGSizeMake(0, 0); // self.layer.shadowRadius = 0.5; self.layer.borderColor = [[UIColor lightGrayColor] CGColor]; self.layer.borderWidth = 0.4f; self.layer.shouldRasterize = YES; self.layer.rasterizationScale = [[UIScreen mainScreen] scale]; self.layer.cornerRadius = 7.0; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/YSLCardView.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
305
```objective-c // // LTSlidingViewController.h // // Created by ltebean on 14/10/31. // #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger, SlideDirection) { SlideDirectionLeft, SlideDirectionRight }; @protocol LTSlidingViewTransition<NSObject> - (void)updateSourceView:(UIView *)sourceView destinationView:(UIView *)destView withProgress:(CGFloat)progress direction:(SlideDirection)direction; @end @interface LTSlidingViewController: UIViewController @property(nonatomic,strong) id<LTSlidingViewTransition>animator; - (void)scrollToPage:(NSInteger)page animated:(BOOL)animated; - (void)removeAllChildViewControllers; - (void)didScrollToPage:(NSInteger)page; @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/LTSlidingViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
160
```objective-c // // LTSlidingViewFlipTransition.m // LTSlidingViewController // // Created by Yu Cong on 14-10-31. // #import "LTSlidingViewCoverflowTransition.h" #define finalAngel 30.0f #define perspective 1.0/-600 #define finalAlpha 0.6f @implementation LTSlidingViewCoverflowTransition - (void)updateSourceView:(UIView *)sourceView destinationView:(UIView *)destView withProgress:(CGFloat)progress direction:(SlideDirection)direction { CATransform3D transform = CATransform3DIdentity; transform.m34 = perspective; CGFloat angle = finalAngel * M_PI / 180.0f * progress; if (direction == SlideDirectionLeft) { angle = -angle; } transform = CATransform3DRotate(transform, angle , 0.0f, 1.0f, 0.0f); sourceView.layer.transform = transform; sourceView.alpha = 1 - progress * (1 - finalAlpha); if (destView) { CATransform3D transform = CATransform3DIdentity; transform.m34 = perspective; CGFloat angle = - finalAngel * M_PI / 180.0f * (1 - progress); if (direction == SlideDirectionLeft) { angle = -angle; } transform = CATransform3DRotate(transform, angle , 0.0f, 1.0f, 0.0f); destView.layer.transform = transform; destView.alpha = finalAlpha + (1 - finalAlpha) * progress; } } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/LTSlidingViewCoverflowTransition.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
364
```objective-c // // YFSlidingViewController.m // BigShow1949 // // Created by zhht01 on 16/3/17. // #import "YFSlidingViewController.h" #import "LTSlidingViewCoverflowTransition.h" #import "LTSlidingViewZoomTransition.h" @implementation YFSlidingViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.animator = [LTSlidingViewCoverflowTransition new]; // self.animator = [LTSlidingViewZoomTransition new]; UIViewController *vc1 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc"]; UIViewController *vc2 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc"]; UIViewController *vc3 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc"]; [self addChildViewController:vc1]; [self addChildViewController:vc2]; [self addChildViewController:vc3]; } - (void)didScrollToPage:(NSInteger)page { NSLog(@"did scroll to page:%ld", (long)page); } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/YFSlidingViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
240
```objective-c // // LTSlidingViewZoomTransition.m // LTSlidingViewController // // Created by Yu Cong on 14-10-31. // #import "LTSlidingViewZoomTransition.h" #define zoom 0.88 #define finalAlpha 0.6f @implementation LTSlidingViewZoomTransition - (void)updateSourceView:(UIView *)sourceView destinationView:(UIView *)destView withProgress:(CGFloat)progress direction:(SlideDirection)direction { CGFloat sourceViewZoom = 1 - (1 - zoom) * progress; sourceView.transform=CGAffineTransformMakeScale(sourceViewZoom, sourceViewZoom); sourceView.alpha = 1 - progress * (1 - finalAlpha); if (destView) { CGFloat destViewZoom = zoom + (1 - zoom) * progress; destView.transform=CGAffineTransformMakeScale(destViewZoom, destViewZoom); destView.alpha = finalAlpha + (1 - finalAlpha) * progress; } } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/LTSlidingViewZoomTransition.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
217
```objective-c // // YFSlidingViewController.h // BigShow1949 // // Created by zhht01 on 16/3/17. // #import <UIKit/UIKit.h> #import "LTSlidingViewController.h" @interface YFSlidingViewController : LTSlidingViewController @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/YFSlidingViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
63
```objective-c // // LTSlidingViewFlipTransition.h // LTSlidingViewController // // Created by Yu Cong on 14-10-31. // #import <Foundation/Foundation.h> #import "LTSlidingViewController.h" @interface LTSlidingViewCoverflowTransition: NSObject<LTSlidingViewTransition> @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/LTSlidingViewCoverflowTransition.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
68
```objective-c // // YSLDraggableCardContainer.m // Crew-iOS // // Created by yamaguchi on 2015/10/22. // #import "YSLDraggableCardContainer.h" static const CGFloat kPreloadViewCount = 3.0f; static const CGFloat kSecondCard_Scale = 0.98f; static const CGFloat kTherdCard_Scale = 0.96f; static const CGFloat kCard_Margin = 7.0f; static const CGFloat kDragCompleteCoefficient_width_default = 0.8f; static const CGFloat kDragCompleteCoefficient_height_default = 0.6f; typedef NS_ENUM(NSInteger, MoveSlope) { // MoveSlopeTop = 1, MoveSlopeBottom = -1 }; @interface YSLDraggableCardContainer () @property (nonatomic, assign) MoveSlope moveSlope; @property (nonatomic, assign) CGRect defaultFrame; @property (nonatomic, assign) CGFloat cardCenterX; // X @property (nonatomic, assign) CGFloat cardCenterY; // Y @property (nonatomic, assign) NSInteger loadedIndex; @property (nonatomic, assign) NSInteger currentIndex; @property (nonatomic, strong) NSMutableArray *currentViews; @property (nonatomic, assign) BOOL isInitialAnimation; @end @implementation YSLDraggableCardContainer - (id)init { self = [super init]; if (self) { [self setUp]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(cardViewTap:)]; [self addGestureRecognizer:tapGesture]; _canDraggableDirection = YSLDraggableDirectionLeft | YSLDraggableDirectionRight; } return self; } - (void)setUp { _moveSlope = MoveSlopeTop; _loadedIndex = 0.0f; _currentIndex = 0.0f; _currentViews = [NSMutableArray array]; } #pragma mark -- Public -(void)reloadCardContainer { for (UIView *view in self.subviews) { [view removeFromSuperview]; } [_currentViews removeAllObjects]; _currentViews = [NSMutableArray array]; [self setUp]; [self loadNextView]; _isInitialAnimation = NO; [self viewInitialAnimation]; } - (void)movePositionWithDirection:(YSLDraggableDirection)direction isAutomatic:(BOOL)isAutomatic undoHandler:(void (^)())undoHandler { [self cardViewDirectionAnimation:direction isAutomatic:isAutomatic undoHandler:undoHandler]; } - (void)movePositionWithDirection:(YSLDraggableDirection)direction isAutomatic:(BOOL)isAutomatic { [self cardViewDirectionAnimation:direction isAutomatic:isAutomatic undoHandler:nil]; } - (UIView *)getCurrentView { return [_currentViews firstObject]; } #pragma mark -- Private - (void)loadNextView { if (self.dataSource && [self.dataSource respondsToSelector:@selector(cardContainerViewNumberOfViewInIndex:)]) { NSInteger index = [self.dataSource cardContainerViewNumberOfViewInIndex:_loadedIndex]; NSLog(@"index = %zd, _loadedIndex = %zd, _currentIndex = %zd", index, _loadedIndex, _currentIndex); // all cardViews Dragging end if (index != 0 && index == _currentIndex) { if (self.delegate && [self.delegate respondsToSelector:@selector(cardContainerViewDidCompleteAll:)]) { [self.delegate cardContainerViewDidCompleteAll:self]; } return; } // load next cardView if (_loadedIndex < index) { NSInteger preloadViewCont = index <= kPreloadViewCount ? index : kPreloadViewCount; for (NSInteger i = _currentViews.count; i < preloadViewCont; i++) { if (self.dataSource && [self.dataSource respondsToSelector:@selector(cardContainerViewNextViewWithIndex:)]) { UIView *view = [self.dataSource cardContainerViewNextViewWithIndex:_loadedIndex]; if (view) { _defaultFrame = view.frame; _cardCenterX = view.center.x; _cardCenterY = view.center.y; [self addSubview:view]; [self sendSubviewToBack:view]; [_currentViews addObject:view]; if (i == 1 && _currentIndex != 0) { view.frame = CGRectMake(_defaultFrame.origin.x, _defaultFrame.origin.y + kCard_Margin, _defaultFrame.size.width, _defaultFrame.size.height); view.transform = CGAffineTransformScale(CGAffineTransformIdentity,kSecondCard_Scale,kSecondCard_Scale); } if (i == 2 && _currentIndex != 0) { view.frame = CGRectMake(_defaultFrame.origin.x, _defaultFrame.origin.y + (kCard_Margin * 2), _defaultFrame.size.width, _defaultFrame.size.height); view.transform = CGAffineTransformScale(CGAffineTransformIdentity,kTherdCard_Scale,kTherdCard_Scale); } _loadedIndex++; } } } } UIView *view = [self getCurrentView]; if (view) { UIPanGestureRecognizer *gesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)]; [view addGestureRecognizer:gesture]; } } } - (void)cardViewDirectionAnimation:(YSLDraggableDirection)direction isAutomatic:(BOOL)isAutomatic undoHandler:(void (^)())undoHandler { if (!_isInitialAnimation) { return; } UIView *view = [self getCurrentView]; if (!view) { return; } __weak YSLDraggableCardContainer *weakself = self; if (direction == YSLDraggableDirectionDefault) { view.transform = CGAffineTransformIdentity; [UIView animateWithDuration:0.55 delay:0.0 usingSpringWithDamping:0.6 initialSpringVelocity:0.0 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction animations:^{ view.frame = _defaultFrame; [weakself cardViewDefaultScale]; } completion:^(BOOL finished) { }]; return; } if (!undoHandler) { [_currentViews removeObject:view]; _currentIndex++; [self loadNextView]; } if (direction == YSLDraggableDirectionRight || direction == YSLDraggableDirectionLeft || direction == YSLDraggableDirectionDown) { [UIView animateWithDuration:0.35 delay:0.0 options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{ if (direction == YSLDraggableDirectionLeft) { view.center = CGPointMake(-1 * (weakself.frame.size.width), view.center.y); if (isAutomatic) { view.transform = CGAffineTransformMakeRotation(-1 * M_PI_4); } } if (direction == YSLDraggableDirectionRight) { view.center = CGPointMake((weakself.frame.size.width * 2), view.center.y); if (isAutomatic) { view.transform = CGAffineTransformMakeRotation(direction * M_PI_4); } } if (direction == YSLDraggableDirectionDown) { view.center = CGPointMake(view.center.x, (weakself.frame.size.height * 1.5)); } if (!undoHandler) { [weakself cardViewDefaultScale]; } } completion:^(BOOL finished) { if (!undoHandler) { [view removeFromSuperview]; } else { if (undoHandler) { undoHandler(); } } }]; } if (direction == YSLDraggableDirectionUp) { [UIView animateWithDuration:0.15 delay:0.0 options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{ if (direction == YSLDraggableDirectionUp) { if (isAutomatic) { view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.03,0.97); view.center = CGPointMake(view.center.x, view.center.y + kCard_Margin); } } } completion:^(BOOL finished) { [UIView animateWithDuration:0.35 delay:0.0 options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{ view.center = CGPointMake(view.center.x, -1 * ((weakself.frame.size.height) / 2)); [weakself cardViewDefaultScale]; } completion:^(BOOL finished) { if (!undoHandler) { [view removeFromSuperview]; } else { if (undoHandler) { undoHandler(); } } }]; }]; } } - (void)cardViewUpDateScale { UIView *view = [self getCurrentView]; float ratio_w = fabs((view.center.x - _cardCenterX) / _cardCenterX); float ratio_h = fabs((view.center.y - _cardCenterY) / _cardCenterY); float ratio = ratio_w > ratio_h ? ratio_w : ratio_h; if (_currentViews.count == 2) { if (ratio <= 1) { UIView *view = _currentViews[1]; view.transform = CGAffineTransformIdentity; view.frame = CGRectMake(_defaultFrame.origin.x, _defaultFrame.origin.y + (kCard_Margin - (ratio * kCard_Margin)), _defaultFrame.size.width, _defaultFrame.size.height); view.transform = CGAffineTransformScale(CGAffineTransformIdentity,kSecondCard_Scale + (ratio * (1 - kSecondCard_Scale)),kSecondCard_Scale + (ratio * (1 - kSecondCard_Scale))); } } if (_currentViews.count == 3) { if (ratio <= 1) { { UIView *view = _currentViews[1]; view.transform = CGAffineTransformIdentity; view.frame = CGRectMake(_defaultFrame.origin.x, _defaultFrame.origin.y + (kCard_Margin - (ratio * kCard_Margin)), _defaultFrame.size.width, _defaultFrame.size.height); view.transform = CGAffineTransformScale(CGAffineTransformIdentity,kSecondCard_Scale + (ratio * (1 - kSecondCard_Scale)),kSecondCard_Scale + (ratio * (1 - kSecondCard_Scale))); } { UIView *view = _currentViews[2]; view.transform = CGAffineTransformIdentity; view.frame = CGRectMake(_defaultFrame.origin.x, _defaultFrame.origin.y + ((kCard_Margin * 2) - (ratio * kCard_Margin)), _defaultFrame.size.width, _defaultFrame.size.height); view.transform = CGAffineTransformScale(CGAffineTransformIdentity,kTherdCard_Scale + (ratio * (kSecondCard_Scale - kTherdCard_Scale)),kTherdCard_Scale + (ratio * (kSecondCard_Scale - kTherdCard_Scale))); } } } } - (void)cardViewDefaultScale { if (self.delegate && [self.delegate respondsToSelector:@selector(cardContainderView:updatePositionWithDraggableView:draggableDirection:widthRatio:heightRatio:)]) { [self.delegate cardContainderView:self updatePositionWithDraggableView:[self getCurrentView] draggableDirection:YSLDraggableDirectionDefault widthRatio:0 heightRatio:0]; } for (int i = 0; i < _currentViews.count; i++) { UIView *view = _currentViews[i]; if (i == 0) { view.transform = CGAffineTransformIdentity; view.frame = _defaultFrame; } if (i == 1) { view.transform = CGAffineTransformIdentity; view.frame = CGRectMake(_defaultFrame.origin.x, _defaultFrame.origin.y + kCard_Margin, _defaultFrame.size.width, _defaultFrame.size.height); view.transform = CGAffineTransformScale(CGAffineTransformIdentity,kSecondCard_Scale,kSecondCard_Scale); } if (i == 2) { view.transform = CGAffineTransformIdentity; view.frame = CGRectMake(_defaultFrame.origin.x, _defaultFrame.origin.y + (kCard_Margin * 2), _defaultFrame.size.width, _defaultFrame.size.height); view.transform = CGAffineTransformScale(CGAffineTransformIdentity,kTherdCard_Scale,kTherdCard_Scale); } } } - (void)viewInitialAnimation { for (UIView *view in _currentViews) { view.alpha = 0.0; } UIView *view = [self getCurrentView]; if (!view) { return; } __weak YSLDraggableCardContainer *weakself = self; view.alpha = 1.0; view.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.5f,0.5f); [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.05f,1.05f); } completion:^(BOOL finished){ [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{ view.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.95f,0.95f); } completion:^(BOOL finished) { [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{ view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.0f,1.0f); } completion:^(BOOL finished) { for (UIView *view in _currentViews) { view.alpha = 1.0; } [UIView animateWithDuration:0.25f delay:0.01f options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction animations:^{ [weakself cardViewDefaultScale]; } completion:^(BOOL finished) { weakself.isInitialAnimation = YES; }]; } ]; } ]; } ]; } #pragma mark -- Gesture Selector - (void)handlePanGesture:(UIPanGestureRecognizer *)gesture { if (!_isInitialAnimation) { return; } if (gesture.state == UIGestureRecognizerStateBegan) { // 1 CGPoint touchPoint = [gesture locationInView:self]; if (touchPoint.y <= _cardCenterY) { // _moveSlope = MoveSlopeTop; } else { _moveSlope = MoveSlopeBottom; } } if (gesture.state == UIGestureRecognizerStateChanged) { // 2 CGPoint point = [gesture translationInView:self]; CGPoint movedPoint = CGPointMake(gesture.view.center.x + point.x, gesture.view.center.y + point.y); NSLog(@"point.y =%f, gesture.view.center.y = %f, movedPoint.y = %f", point.y, gesture.view.center.y, movedPoint.y); gesture.view.center = movedPoint; [gesture.view setTransform: CGAffineTransformMakeRotation((gesture.view.center.y - _cardCenterY) / _cardCenterY * (_moveSlope * (M_PI / 20)))]; NSLog(@"scale = %f", (gesture.view.center.y - _cardCenterY) / _cardCenterY); NSLog(@"make = %f", (gesture.view.center.y - _cardCenterY) / _cardCenterY * (_moveSlope * (M_PI / 20))); [self cardViewUpDateScale]; if (self.delegate && [self.delegate respondsToSelector:@selector(cardContainderView:updatePositionWithDraggableView:draggableDirection:widthRatio:heightRatio:)]) { if ([self getCurrentView]) { float ratio_w = (gesture.view.center.x - _cardCenterX) / _cardCenterX; float ratio_h = (gesture.view.center.y - _cardCenterY) / _cardCenterY; YSLDraggableDirection direction = YSLDraggableDirectionDefault; if (fabs(ratio_h) > fabs(ratio_w)) { // Q:, ? if (ratio_h <= 0) { // up if (_canDraggableDirection & YSLDraggableDirectionUp) { direction = YSLDraggableDirectionUp; } else { direction = ratio_w <= 0 ? YSLDraggableDirectionLeft : YSLDraggableDirectionRight; } } else { // down if (_canDraggableDirection & YSLDraggableDirectionDown) { direction = YSLDraggableDirectionDown; } else { direction = ratio_w <= 0 ? YSLDraggableDirectionLeft : YSLDraggableDirectionRight; } } } else { if (ratio_w <= 0) { // left if (_canDraggableDirection & YSLDraggableDirectionLeft) { direction = YSLDraggableDirectionLeft; } else { direction = ratio_h <= 0 ? YSLDraggableDirectionUp : YSLDraggableDirectionDown; } } else { // right if (_canDraggableDirection & YSLDraggableDirectionRight) { direction = YSLDraggableDirectionRight; } else { direction = ratio_h <= 0 ? YSLDraggableDirectionUp : YSLDraggableDirectionDown; } } } [self.delegate cardContainderView:self updatePositionWithDraggableView:gesture.view draggableDirection:direction widthRatio:fabs(ratio_w) heightRatio:fabsf(ratio_h)]; } } CGPoint prePoint = [gesture translationInView:self]; // NSLog(@"gesture.x = %f, gesture.y = %f", prePoint.x, prePoint.y); [gesture setTranslation:CGPointZero inView:self]; CGPoint suffixPoint = [gesture translationInView:self]; // NSLog(@"gesture.x = %f, gesture.y = %f", suffixPoint.x, suffixPoint.y); } if (gesture.state == UIGestureRecognizerStateEnded || gesture.state == UIGestureRecognizerStateCancelled) { // 3 4 // NSLog(@"gesture.view.center.y = %f, _cardCenterY = %f", gesture.view.center.y , _cardCenterY); float ratio_w = (gesture.view.center.x - _cardCenterX) / _cardCenterX; float ratio_h = (gesture.view.center.y - _cardCenterY) / _cardCenterY; // NSLog(@"ratio_w = %f, ratio_h = %f", ratio_w, ratio_h); YSLDraggableDirection direction = YSLDraggableDirectionDefault; if (fabs(ratio_h) > fabs(ratio_w)) { // NSLog(@"_canDraggableDirection = %zd, YSLDraggableDirectionDown = %zd", _canDraggableDirection, YSLDraggableDirectionDown); // NSLog(@"_canDraggableDirection & YSLDraggableDirectionUp = %zd", _canDraggableDirection & YSLDraggableDirectionUp); // NSLog(@"kDragCompleteCoefficient_height_default = %f", kDragCompleteCoefficient_height_default); // NSLog(@"kDragCompleteCoefficient_height_default && (_canDraggableDirection & YSLDraggableDirectionDown) = %zd", kDragCompleteCoefficient_height_default && (_canDraggableDirection & YSLDraggableDirectionDown)); if (ratio_h < - kDragCompleteCoefficient_height_default && (_canDraggableDirection & YSLDraggableDirectionUp)) { // up NSLog(@"_canDraggableDirection = %zd, YSLDraggableDirectionUp = %zd", _canDraggableDirection, YSLDraggableDirectionUp); NSLog(@"_canDraggableDirection & YSLDraggableDirectionUp = %zd", _canDraggableDirection & YSLDraggableDirectionUp); NSLog(@"ratio_h = %f, -kDragCompleteCoefficient_height_default = %f", ratio_h, -kDragCompleteCoefficient_height_default); direction = YSLDraggableDirectionUp; } NSLog(@"ratio_h = %f, = %d", ratio_h, kDragCompleteCoefficient_height_default && (_canDraggableDirection & YSLDraggableDirectionDown)); if (ratio_h > kDragCompleteCoefficient_height_default && !(_canDraggableDirection & YSLDraggableDirectionDown)) { // down direction = YSLDraggableDirectionDown; } }else { if (ratio_w > kDragCompleteCoefficient_width_default && (_canDraggableDirection & YSLDraggableDirectionRight)) { // right direction = YSLDraggableDirectionRight; } if (ratio_w < - kDragCompleteCoefficient_width_default && (_canDraggableDirection & YSLDraggableDirectionLeft)) { // left direction = YSLDraggableDirectionLeft; } } if (direction == YSLDraggableDirectionDefault) { [self cardViewDirectionAnimation:YSLDraggableDirectionDefault isAutomatic:NO undoHandler:nil]; } else { if (self.delegate && [self.delegate respondsToSelector:@selector(cardContainerView:didEndDraggingAtIndex:draggableView:draggableDirection:)]) { [self.delegate cardContainerView:self didEndDraggingAtIndex:_currentIndex draggableView:gesture.view draggableDirection:direction]; } } } } - (void)cardViewTap:(UITapGestureRecognizer *)gesture { if (!_currentViews || _currentViews.count == 0) { return; } if (self.delegate && [self.delegate respondsToSelector:@selector(cardContainerView:didSelectAtIndex:draggableView:)]) { [self.delegate cardContainerView:self didSelectAtIndex:_currentIndex draggableView:gesture.view]; } } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/DraggableCard/YSLDraggableCardContainer.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
4,700
```objective-c // // LTSlidingViewZoomTransition.h // LTSlidingViewController // // Created by Yu Cong on 14-10-31. // #import <Foundation/Foundation.h> #import "LTSlidingViewController.h" @interface LTSlidingViewZoomTransition: NSObject<LTSlidingViewTransition> @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/LTSlidingViewZoomTransition.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
67
```objective-c // // TempViewController.h // YXDemo1 // // Created by k1er on 16/1/6. // #import <UIKit/UIKit.h> @interface TempViewController : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/BaiduViewTransition/TempViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
46
```objective-c // // LTSlidingViewController..m // // Created by ltebean on 14/10/31. // #import "LTSlidingViewController.h" @interface LTSlidingViewController ()<UIScrollViewDelegate> @property (nonatomic,strong) UIScrollView *scrollView; @property (nonatomic) CGFloat beginOffset; @property (nonatomic) NSInteger currentPage; @end @implementation LTSlidingViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.currentPage = 0; } - (UIScrollView*)scrollView { if (!_scrollView) { _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds))]; _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; _scrollView.delegate = self; _scrollView.pagingEnabled = YES; _scrollView.showsHorizontalScrollIndicator = NO; _scrollView.showsVerticalScrollIndicator = NO; [self.view addSubview:_scrollView]; } return _scrollView; } - (void)addChildViewController:(UIViewController *)childController { CGFloat width = CGRectGetWidth(self.view.bounds); CGFloat height = CGRectGetHeight(self.view.bounds); childController.view.frame = CGRectMake(width * self.childViewControllers.count, 0, width, height); [self.scrollView addSubview:childController.view]; [super addChildViewController:childController]; [childController didMoveToParentViewController:self]; self.scrollView.contentSize = CGSizeMake(width * self.childViewControllers.count, height); } - (void)removeAllChildViewControllers { [self.childViewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { UIViewController *vc = (UIViewController *)obj; [vc willMoveToParentViewController:nil]; [vc.view removeFromSuperview]; [vc removeFromParentViewController]; self.scrollView.contentSize = CGSizeMake(0, CGRectGetHeight(self.view.bounds)); }]; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat pageWidth = self.scrollView.frame.size.width; CGFloat offset = self.scrollView.contentOffset.x; CGFloat progress = MIN(1,fabs((offset - self.beginOffset)/pageWidth)); UIViewController *sourceVC = self.childViewControllers[self.currentPage]; UIView *sourceView = sourceVC.view; UIView *destView; SlideDirection direction = self.slideDirection; NSInteger nextPage = direction == SlideDirectionRight ? self.currentPage + 1 : self.currentPage - 1; if (nextPage >= 0 && nextPage < self.childViewControllers.count) { UIViewController *destinationVC = self.childViewControllers[nextPage]; destView = destinationVC.view; } if (self.animator) { [self.animator updateSourceView:sourceView destinationView:destView withProgress:progress direction:direction]; } } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { self.beginOffset = self.scrollView.contentOffset.x; self.currentPage = [self calculateCurrentPage]; } - (NSInteger)calculateCurrentPage { CGFloat pageWidth = CGRectGetWidth(self.view.bounds); return floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { self.currentPage = [self calculateCurrentPage]; UIViewController *destinationVC = self.childViewControllers[self.currentPage]; [self.animator updateSourceView:nil destinationView:destinationVC.view withProgress:1 direction:self.slideDirection]; [self didScrollToPage:self.currentPage]; } - (SlideDirection)slideDirection { return self.scrollView.contentOffset.x > self.beginOffset ? SlideDirectionRight : SlideDirectionLeft; } - (void)scrollToPage:(NSInteger)page animated:(BOOL)animated; { CGFloat pageWidth = CGRectGetWidth(self.view.bounds); CGPoint offset = CGPointMake(pageWidth * page, 0); [self.scrollView setContentOffset:offset animated:animated]; } - (void)didScrollToPage:(NSInteger)page { } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/LTSlidingViewController/LTSlidingViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
845
```objective-c // // YFBaiduViewTransitionViewController.h // BigShow1949 // // Created by zhht01 on 16/3/17. // #import <UIKit/UIKit.h> @interface YFBaiduViewTransitionViewController : UIViewController @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/BaiduViewTransition/YFBaiduViewTransitionViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
54
```objective-c // // TempViewController.m // YXDemo1 // // Created by k1er on 16/1/6. // #define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A] #define ScreenSize [UIScreen mainScreen].bounds.size #import "TempViewController.h" @interface TempViewController () { CGFloat screenWidth; CGFloat screenHeight; } @end @implementation TempViewController - (void)viewDidLoad { [super viewDidLoad]; [self.view setBackgroundColor:[UIColor whiteColor]]; [self initData]; [self initViews]; } - (void)initData { screenWidth = [UIScreen mainScreen].bounds.size.width; screenHeight = [UIScreen mainScreen].bounds.size.height; } - (void)initViews { UIView *toolView = [[UIView alloc] initWithFrame:CGRectMake(0, screenHeight - 44, screenWidth, 44)]; [toolView setBackgroundColor:[UIColor whiteColor]]; [self.view addSubview:toolView]; UIButton *showBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 12, 120, 20)]; [showBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; [showBtn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted]; [showBtn setTitle:@"" forState:UIControlStateNormal]; [showBtn addTarget:self action:@selector(showViewControllerList) forControlEvents:UIControlEventTouchUpInside]; [toolView addSubview:showBtn]; } - (void)showViewControllerList { [[NSNotificationCenter defaultCenter] postNotificationName:@"showVCList" object:nil]; } @end // // path_to_url (cn) path_to_url (en) // : Code4App.com ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/BaiduViewTransition/TempViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
352
```objective-c // // SwiftViewController.h // BigShow1949 // // Created by apple on 17/2/16. // #import "BaseTableViewController.h" @interface SwiftViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/16 - Swift专栏/SwiftViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
47
```objective-c // // Use this file to import your target's public headers that you would like to expose to Swift. // ```
/content/code_sandbox/BigShow1949/Classes/16 - Swift专栏/BigShow1949-Bridging-Header.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
24
```objective-c // // SwiftViewController.m // BigShow1949 // // Created by apple on 17/2/16. // #import "SwiftViewController.h" @interface SwiftViewController () @end @implementation SwiftViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupDataArr:@[@[@"tableView",@"_TtC7BigShow26SpreadViewController_swift"]]]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end ```
/content/code_sandbox/BigShow1949/Classes/16 - Swift专栏/SwiftViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
171
```swift // // HelpTableCell.swift // TableViewSpread-swift // // Created by pxh on 2016/11/18. // import UIKit class HelpTableCell: UITableViewCell { @IBOutlet weak var cellTitle: UILabel! override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func layoutSubviews() { super.layoutSubviews() print("layoutSubviews") } override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state } } ```
/content/code_sandbox/BigShow1949/Classes/16 - Swift专栏/SpreadTableView/HelpTableCell.swift
swift
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
128
```swift // // HelpSectionHeader.swift // SpreadTableView // // Created by apple on 17/2/14. // import UIKit class HelpSectionHeader: UIView { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var spreadBtn: UIButton! typealias callBackBlock = (_ index : NSInteger,_ isSelected : Bool) -> () var spreadBlock : callBackBlock! override init(frame: CGRect) { super.init(frame: frame) awakeFromNib() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func awakeFromNib() { super.awakeFromNib() self.backgroundColor = UIColor.red let subView : UIView = Bundle.main.loadNibNamed("HelpSectionHeader", owner: self, options: nil)?.first as! UIView subView.frame = self.frame self.addSubview(subView) spreadBtn.tintColor = UIColor.clear } override func layoutSubviews() { super.layoutSubviews() } @IBAction func spreadBtnAction(_ sender: UIButton) { sender.isSelected = !sender.isSelected if let _ = spreadBlock { spreadBlock(self.tag, sender.isSelected) } } } ```
/content/code_sandbox/BigShow1949/Classes/16 - Swift专栏/SpreadTableView/HelpSectionHeader.swift
swift
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
265
```objective-c // // YFBaiduViewTransitionViewController.m // BigShow1949 // // Created by zhht01 on 16/3/17. // #import "YFBaiduViewTransitionViewController.h" #import "TempViewController.h" #define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A] #define ScreenSize [UIScreen mainScreen].bounds.size @interface YFBaiduViewTransitionViewController ()<UITableViewDataSource, UITableViewDelegate> { UIView *currentVisibleView; NSMutableArray *allViews; UIView *maskView; // UIView *tarBarView; UIView *tarBarToolView; CGFloat screenWidth; CGFloat screenHeight; NSArray *tableviewArr; UITableView *viewList; NSInteger currentViewIndex; } @property (nonatomic, strong) UIView *tarBarView; @end @implementation YFBaiduViewTransitionViewController typedef enum { ShowViewDirectionLeftToRight = 0, ShowViewDirectionRightToLeft = 1, }ShowViewDirection; - (void)viewDidLoad { [super viewDidLoad]; [self initData]; [self initViews]; // Do any additional setup after loading the view, typically from a nib. } - (void)initData { screenWidth = [UIScreen mainScreen].bounds.size.width; screenHeight = [UIScreen mainScreen].bounds.size.height; } - (void)initViews { TempViewController *rootViewController = [[TempViewController alloc] init]; [self addChildViewController:rootViewController]; [self.view setBackgroundColor:[UIColor blackColor]]; currentVisibleView = rootViewController.view; [self.view addSubview:rootViewController.view]; allViews = [[NSMutableArray alloc] init]; [allViews addObject:rootViewController.view]; [rootViewController setTitle:@""]; tableviewArr = [NSArray arrayWithObject:@""]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showViewControllerList:) name:@"showVCList" object:nil]; currentViewIndex = 1; maskView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds]; [maskView setBackgroundColor:[UIColor blackColor]]; [maskView setAlpha:0]; UITapGestureRecognizer *reAnGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reAnGRAction)]; [maskView addGestureRecognizer:reAnGR]; [viewList setBackgroundColor:[UIColor purpleColor]]; [self.tarBarView addSubview:viewList]; [viewList setDataSource:self]; [viewList setDelegate:self]; [viewList setShowsVerticalScrollIndicator:NO]; [viewList setTransform: CGAffineTransformMakeRotation(-M_PI / 2)]; [viewList setSeparatorStyle:UITableViewCellSeparatorStyleNone]; } - (void)addViewController { TempViewController *subVC = [[TempViewController alloc] init]; [self addChildViewController:subVC]; [subVC setTitle:@""]; NSMutableArray *arr = [NSMutableArray arrayWithArray:tableviewArr]; [arr addObject:@""]; tableviewArr = arr; [viewList beginUpdates]; [viewList insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:arr.count-1 inSection:0]] withRowAnimation:UITableViewRowAnimationRight]; [viewList endUpdates]; [viewList scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionBottom animated:YES]; [allViews addObject:subVC.view]; [self.view insertSubview:subVC.view belowSubview:maskView]; [self showViewToScreen:currentVisibleView next:subVC.view direction:ShowViewDirectionRightToLeft currViewIndex:tableviewArr.count]; } - (void)showViewControllerList:(NSNotification *)notification { [self animateForView:currentVisibleView]; } - (void)showViewToScreen:(UIView *)preView next:(UIView *)nextView direction:(ShowViewDirection)dir currViewIndex:(NSInteger)index { CGRect showFrame = [UIScreen mainScreen].bounds; CGRect frameOfPreView = showFrame; CGRect frameOfNextView = showFrame; CGRect unVisibelFrame = showFrame; unVisibelFrame.origin.y += screenHeight; for (UIView *view in allViews) { if (view != preView && view != nextView) { [view setFrame:unVisibelFrame]; } } if (dir == ShowViewDirectionRightToLeft) { frameOfPreView.origin.x = showFrame.origin.x - screenWidth; frameOfNextView.origin.x = showFrame.origin.x + screenWidth; [nextView setFrame:frameOfNextView]; [nextView.layer setTransform:[self secondTransformWithView:nextView]]; }else{ frameOfPreView.origin.x = showFrame.origin.x + screenWidth; frameOfNextView.origin.x = showFrame.origin.x - screenWidth; [nextView setFrame:frameOfNextView]; [nextView.layer setTransform:[self secondTransformWithView:nextView]]; } [UIView animateWithDuration:0.35 animations:^{ [preView setFrame:frameOfPreView]; [nextView setFrame:showFrame]; } completion:^(BOOL finished){ currentVisibleView = nextView; currentViewIndex = index; [self reAnimateForView:currentVisibleView]; }]; } - (void)reAnGRAction { [self reAnimateForView:currentVisibleView]; } - (void)animateForView:(UIView *)view { [self.view addSubview:maskView]; CGRect frame = [self.tarBarView frame]; frame.origin.y = screenHeight - 340; [UIView animateWithDuration:0.2f animations:^{ [view.layer setTransform:[self firstTransform]]; } completion:^(BOOL finished){ [UIView animateWithDuration:0.2f animations:^{ [view.layer setTransform:[self secondTransformWithView:view]]; } completion:^(BOOL finished){ [UIView animateWithDuration:0.2 animations:^{ [maskView setAlpha:0.5f]; [self.tarBarView setFrame:frame]; }]; }]; }]; [self.view bringSubviewToFront:self.tarBarView]; } - (void)reAnimateForView:(UIView *)view { CGRect frame = [self.tarBarView frame]; frame.origin.y += 340; [UIView animateWithDuration:0.2f animations:^{ [maskView setAlpha:0.f]; [self.tarBarView setFrame:frame]; } completion:^(BOOL finished){ [UIView animateWithDuration:0.2f animations:^{ [maskView removeFromSuperview]; [view.layer setTransform:[self firstTransform]]; } completion:^(BOOL finished){ [UIView animateWithDuration:0.2f animations:^{ [view.layer setTransform:CATransform3DIdentity]; }]; }]; }]; } -(CATransform3D)firstTransform{ CATransform3D t1 = CATransform3DIdentity; t1.m34 = 1.0/-900; t1 = CATransform3DScale(t1, 0.95, 0.95, 1); t1 = CATransform3DRotate(t1, 15.0f * M_PI/180.0f, 1, 0, 0); return t1; } -(CATransform3D)secondTransformWithView:(UIView*)view{ CATransform3D t2 = CATransform3DIdentity; t2.m34 = [self firstTransform].m34; t2 = CATransform3DTranslate(t2, 0, view.frame.size.height*-0.08, 0); t2 = CATransform3DScale(t2, 0.8, 0.8, 1); return t2; } #pragma mark UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return tableviewArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; [cell.contentView setBackgroundColor:[UIColor greenColor]]; cell.contentView.transform = CGAffineTransformMakeRotation(M_PI / 2); UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(20, 40, 140, screenWidth - 100)]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; [imgV setBackgroundColor:[UIColor yellowColor]]; [imgV setTag:2015]; UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 15, 140, 20)]; [titleLabel setText:@""]; [cell.contentView addSubview:titleLabel]; [titleLabel setTextAlignment:NSTextAlignmentCenter]; [titleLabel setTag:2016]; [cell.contentView addSubview:imgV]; } UILabel *label = (UILabel *)[cell viewWithTag:2016]; NSString *title = (NSString *)[tableviewArr objectAtIndex:indexPath.row]; [label setText:title]; return cell; } #pragma mark UITableViewDelegate - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 180; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIView *view = (UIView *)[allViews objectAtIndex:(indexPath.row)]; NSInteger cmp = currentViewIndex - 1; NSInteger row = indexPath.row; if (row == cmp) { [self reAnGRAction]; return; } if (row > cmp) { [self showViewToScreen:currentVisibleView next:view direction:ShowViewDirectionRightToLeft currViewIndex:indexPath.row+1]; }else{ [self showViewToScreen:currentVisibleView next:view direction:ShowViewDirectionLeftToRight currViewIndex:indexPath.row+1]; } } #pragma mark - setter - (UIView *)tarBarView { if (!_tarBarView) { _tarBarView = [[UIView alloc] initWithFrame:CGRectMake(0, screenHeight, screenWidth, 340)]; [_tarBarView setBackgroundColor:[UIColor whiteColor]]; tarBarToolView = [[UIView alloc] initWithFrame:CGRectMake(0, 340 - 44, screenWidth, 44)]; [tarBarToolView setBackgroundColor:COLOR(57, 107, 117, 1)]; [_tarBarView addSubview:tarBarToolView]; [self.view addSubview:_tarBarView]; UIButton *addBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 12, 80, 20)]; [addBtn setTitleColor:COLOR(231, 231, 231, 1) forState:UIControlStateNormal]; [addBtn setTitleColor:COLOR(231, 231, 231, 1) forState:UIControlStateHighlighted]; [addBtn setTitle:@"" forState:UIControlStateNormal]; [addBtn addTarget:self action:@selector(addViewController) forControlEvents:UIControlEventTouchUpInside]; [tarBarToolView addSubview:addBtn]; UIButton *finishBtn = [[UIButton alloc] initWithFrame:CGRectMake(screenWidth - 50, 12, 40, 20)]; [finishBtn setTitleColor:COLOR(231, 231, 231, 1) forState:UIControlStateNormal]; [finishBtn setTitleColor:COLOR(231, 231, 231, 1) forState:UIControlStateHighlighted]; [finishBtn setTitle:@"" forState:UIControlStateNormal]; [finishBtn addTarget:self action:@selector(reAnGRAction) forControlEvents:UIControlEventTouchUpInside]; [tarBarToolView addSubview:finishBtn]; if (screenWidth == 320) { viewList = [[UITableView alloc] initWithFrame:CGRectMake(20, -10, 276, screenWidth)]; }else if (screenWidth == 375) { viewList = [[UITableView alloc] initWithFrame:CGRectMake(50, -40, 276, screenWidth)]; }else{ viewList = [[UITableView alloc] initWithFrame:CGRectMake(70, -60, 276, screenWidth)]; } } return _tarBarView; } @end ```
/content/code_sandbox/BigShow1949/Classes/04 - ViewTransition(视图切换)/BaiduViewTransition/YFBaiduViewTransitionViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
2,512
```swift // // SpreadViewController_swift.swift // BigShow1949 // // Created by apple on 17/2/20. // import UIKit class SpreadViewController_swift: UIViewController,UITableViewDataSource,UITableViewDelegate { var tableview: UITableView! let sentionTitles = ["","WIFI","/",""] let cellTitles = [" ", "WIFI >WLAN WIFIWIFI WIFI ", " 5", "5G WIFI WIFI "] let flagArray : NSMutableArray = NSMutableArray() let cellArray : NSMutableArray = NSMutableArray() override func viewDidLoad() { super.viewDidLoad() self.makeData() self.setupTableView() self.automaticallyAdjustsScrollViewInsets = false } func makeData() { for _ : NSInteger in 0...sentionTitles.count - 1 { flagArray.add(false) } } func setupTableView() { tableview = UITableView.init(frame: CGRect(x:0, y:64, width:self.view.frame.size.width, height:self.view.frame.size.height), style: .plain) tableview.delegate = self tableview.dataSource = self tableview.backgroundColor = UIColor.white tableview.tableFooterView = UIView.init() tableview.separatorStyle = UITableViewCell.SeparatorStyle.none tableview.estimatedRowHeight = 200 tableview.rowHeight = UITableView.automaticDimension self.view.addSubview(tableview) } //MARK:-UITableViewDelegate func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { print(indexPath.row) } //MARK:-UITableViewDataSource func numberOfSections(in tableView: UITableView) -> Int { return sentionTitles.count } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if flagArray[section] as! Bool { return 1 }else { return 0 } } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 52 } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = HelpSectionHeader() view.tag = section + 2000 view.spreadBtn.isSelected = flagArray[section] as! Bool view.spreadBlock = {(index : NSInteger,isSelected : Bool) in print(index) let ration : NSInteger = index - 2000 if self.flagArray[ration] as! Bool { self.flagArray[ration] = false }else { self.flagArray[ration] = true } self.tableview.reloadSections(IndexSet.init(integer: index - 2000), with: UITableView.RowAnimation.automatic) } view.titleLabel.text = sentionTitles[section] return view } // func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { // return UITableViewAutomaticDimension // } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let identifier = "cell\(indexPath.section)\(indexPath.row)" self.tableview.register(UINib.init(nibName: "HelpTableCell", bundle: Bundle.main), forCellReuseIdentifier: identifier) let cell : HelpTableCell = tableview.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! HelpTableCell let content : String = cellTitles[indexPath.section] let attributesString = NSMutableAttributedString.init(string : content) //NSMutableParagraphStyle let paraghStyle = NSMutableParagraphStyle() // paraghStyle.lineSpacing = cell.cellTitle.font.lineHeight // attributesString.addAttributes([NSAttributedString.Key.paragraphStyle : paraghStyle], range: NSMakeRange(0, content.count)) cell.cellTitle.attributedText = attributesString cell.selectionStyle = UITableViewCell.SelectionStyle.none return cell } } ```
/content/code_sandbox/BigShow1949/Classes/16 - Swift专栏/SpreadTableView/SpreadViewController_swift.swift
swift
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
833
```objective-c // // YFToolsViewController.m // BigShow1949 // // Created by zhht01 on 16/3/31. // #import "YFToolsViewController.h" @interface YFToolsViewController () @end @implementation YFToolsViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupDataArr:@[@[@"",@"YFColorViewController_UIStoryboard"], @[@"",@"YFImageCategoryViewController"], @[@"",@"YFEmptyDataSetViewController_UIStoryboard"], @[@"",@"YFButtonCategoryViewController"], @[@"",@"YFSafeObjectViewController"],]]; } @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/YFToolsViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
130
```objective-c // // YFToolsViewController.h // BigShow1949 // // Created by zhht01 on 16/3/31. // #import "BaseTableViewController.h" @interface YFToolsViewController : BaseTableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/YFToolsViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
53
```objective-c // // YFEmptyDataSetViewController.h // BigShow1949 // // Created by zhht01 on 16/4/5. // #import <UIKit/UIKit.h> @interface YFEmptyDataSetViewController : UITableViewController @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/EmptyDataSet/YFEmptyDataSetViewController.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
52
```objective-c // // YFEmptyDataSetViewController.m // BigShow1949 // // Created by zhht01 on 16/4/5. // #import "YFEmptyDataSetViewController.h" #import "GzwTableViewLoading.h" @interface YFEmptyDataSetViewController () @property (nonatomic,strong) NSMutableArray *data; @end @implementation YFEmptyDataSetViewController -(NSMutableArray *)data { if (!_data) { _data = [NSMutableArray array]; } return _data; } - (void)viewDidLoad { [super viewDidLoad]; // tableViewFooterViewtableViewcell self.tableView.tableFooterView = [UIView new]; // // self.tableView.buttonText = @""; // self.tableView.buttonNormalColor = [UIColor redColor]; // self.tableView.buttonHighlightColor = [UIColor yellowColor]; // self.tableView.loadedImageName = @"58x58"; // self.tableView.descriptionText = @""; // self.tableView.dataVerticalOffset = 200; // [self.tableView gzwLoading:^{ NSLog(@""); [self loadingData:NO]; }]; } // - (IBAction)loadData:(id)sender { [self loadingData:YES]; } // - (IBAction)noData:(id)sender { [self loadingData:NO]; } -(void)loadingData:(BOOL)data { if (self.data.count > 0) { [self.data removeAllObjects]; [self.tableView reloadData]; } // self.tableView.loading = YES; // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ if (data) { for (int i = 0; i < 10; i++) { [self.data addObject:[NSString stringWithFormat:@"I'm datafuck"]]; } }else {// self.tableView.loading = NO; } [self.tableView reloadData]; }); } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.data.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ID"]; cell.textLabel.text = self.data[indexPath.row]; return cell; } @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/EmptyDataSet/YFEmptyDataSetViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
482
```objective-c // // UIScrollView+EmptyDataSet.h // DZNEmptyDataSet // path_to_url // // Created by Ignacio Romero Zurbuchen on 6/20/14. // Licence: MIT-Licence // #import <UIKit/UIKit.h> @protocol DZNEmptyDataSetSource; @protocol DZNEmptyDataSetDelegate; /** A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display. @discussion It will work automatically, by just conforming to DZNEmptyDataSetSource, and returning the data you want to show. */ @interface UIScrollView (EmptyDataSet) /** The empty datasets data source. */ @property (nonatomic, weak) IBOutlet id <DZNEmptyDataSetSource> emptyDataSetSource; /** The empty datasets delegate. */ @property (nonatomic, weak) IBOutlet id <DZNEmptyDataSetDelegate> emptyDataSetDelegate; /** YES if any empty dataset is visible. */ @property (nonatomic, readonly, getter = isEmptyDataSetVisible) BOOL emptyDataSetVisible; /** Reloads the empty dataset content receiver. @discussion Call this method to force all the data to refresh. Calling -reloadData is similar, but this forces only the empty dataset to reload, not the entire table view or collection view. */ - (void)reloadEmptyDataSet; @end /** The object that acts as the data source of the empty datasets. @discussion The data source must adopt the DZNEmptyDataSetSource protocol. The data source is not retained. All data source methods are optional. */ @protocol DZNEmptyDataSetSource <NSObject> @optional /** Asks the data source for the title of the dataset. The dataset uses a fixed font style by default, if no attributes are set. If you want a different font style, return a attributed string. @param scrollView A scrollView subclass informing the data source. @return An attributed string for the dataset title, combining font, text color, text pararaph style, etc. */ - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView; /** Asks the data source for the description of the dataset. The dataset uses a fixed font style by default, if no attributes are set. If you want a different font style, return a attributed string. @param scrollView A scrollView subclass informing the data source. @return An attributed string for the dataset description text, combining font, text color, text pararaph style, etc. */ - (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView; /** Asks the data source for the image of the dataset. @param scrollView A scrollView subclass informing the data source. @return An image for the dataset. */ - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView; /** Asks the data source for a tint color of the image dataset. Default is nil. @param scrollView A scrollView subclass object informing the data source. @return A color to tint the image of the dataset. */ - (UIColor *)imageTintColorForEmptyDataSet:(UIScrollView *)scrollView; /** * Asks the data source for the image animation of the dataset. * * @param scrollView A scrollView subclass object informing the delegate. * * @return image animation */ - (CAAnimation *) imageAnimationForEmptyDataSet:(UIScrollView *) scrollView; /** Asks the data source for the title to be used for the specified button state. The dataset uses a fixed font style by default, if no attributes are set. If you want a different font style, return a attributed string. @param scrollView A scrollView subclass object informing the data source. @param state The state that uses the specified title. The possible values are described in UIControlState. @return An attributed string for the dataset button title, combining font, text color, text pararaph style, etc. */ - (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state; /** Asks the data source for the image to be used for the specified button state. This method will override buttonTitleForEmptyDataSet:forState: and present the image only without any text. @param scrollView A scrollView subclass object informing the data source. @param state The state that uses the specified title. The possible values are described in UIControlState. @return An image for the dataset button imageview. */ - (UIImage *)buttonImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state; /** Asks the data source for a background image to be used for the specified button state. There is no default style for this call. @param scrollView A scrollView subclass informing the data source. @param state The state that uses the specified image. The values are described in UIControlState. @return An attributed string for the dataset button title, combining font, text color, text pararaph style, etc. */ - (UIImage *)buttonBackgroundImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state; /** Asks the data source for the background color of the dataset. Default is clear color. @param scrollView A scrollView subclass object informing the data source. @return A color to be applied to the dataset background view. */ - (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView; /** Asks the data source for a custom view to be displayed instead of the default views such as labels, imageview and button. Default is nil. Use this method to show an activity view indicator for loading feedback, or for complete custom empty data set. Returning a custom view will ignore -offsetForEmptyDataSet and -spaceHeightForEmptyDataSet configurations. @param scrollView A scrollView subclass object informing the delegate. @return The custom view. */ - (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView; /** Asks the data source for a offset for vertical and horizontal alignment of the content. Default is CGPointZero. @param scrollView A scrollView subclass object informing the delegate. @return The offset for vertical and horizontal alignment. */ - (CGPoint)offsetForEmptyDataSet:(UIScrollView *)scrollView DEPRECATED_MSG_ATTRIBUTE("Use -verticalOffsetForEmptyDataSet:"); - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView; /** Asks the data source for a vertical space between elements. Default is 11 pts. @param scrollView A scrollView subclass object informing the delegate. @return The space height between elements. */ - (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView; @end /** The object that acts as the delegate of the empty datasets. @discussion The delegate can adopt the DZNEmptyDataSetDelegate protocol. The delegate is not retained. All delegate methods are optional. @discussion All delegate methods are optional. Use this delegate for receiving action callbacks. */ @protocol DZNEmptyDataSetDelegate <NSObject> @optional /** Asks the delegate to know if the empty dataset should fade in when displayed. Default is YES. @param scrollView A scrollView subclass object informing the delegate. @return YES if the empty dataset should fade in. */ - (BOOL)emptyDataSetShouldFadeIn:(UIScrollView *)scrollView; /** Asks the delegate to know if the empty dataset should be rendered and displayed. Default is YES. @param scrollView A scrollView subclass object informing the delegate. @return YES if the empty dataset should show. */ - (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView; /** Asks the delegate for touch permission. Default is YES. @param scrollView A scrollView subclass object informing the delegate. @return YES if the empty dataset receives touch gestures. */ - (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView; /** Asks the delegate for scroll permission. Default is NO. @param scrollView A scrollView subclass object informing the delegate. @return YES if the empty dataset is allowed to be scrollable. */ - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView; /** Asks the delegate for image view animation permission. Default is NO. Make sure to return a valid CAAnimation object from imageAnimationForEmptyDataSet: @param scrollView A scrollView subclass object informing the delegate. @return YES if the empty dataset is allowed to animate */ - (BOOL)emptyDataSetShouldAnimateImageView:(UIScrollView *)scrollView; /** Tells the delegate that the empty dataset view was tapped. Use this method either to resignFirstResponder of a textfield or searchBar. @param scrollView A scrollView subclass informing the delegate. */ - (void)emptyDataSetDidTapView:(UIScrollView *)scrollView DEPRECATED_MSG_ATTRIBUTE("Use emptyDataSet:didTapView:"); /** Tells the delegate that the action button was tapped. @param scrollView A scrollView subclass informing the delegate. */ - (void)emptyDataSetDidTapButton:(UIScrollView *)scrollView DEPRECATED_MSG_ATTRIBUTE("Use emptyDataSet:didTapButton:"); /** Tells the delegate that the empty dataset view was tapped. Use this method either to resignFirstResponder of a textfield or searchBar. @param scrollView A scrollView subclass informing the delegate. @param view the view tapped by the user */ - (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view; /** Tells the delegate that the action button was tapped. @param scrollView A scrollView subclass informing the delegate. @param button the button tapped by the user */ - (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button; /** Tells the delegate that the empty data set will appear. @param scrollView A scrollView subclass informing the delegate. */ - (void)emptyDataSetWillAppear:(UIScrollView *)scrollView; /** Tells the delegate that the empty data set did appear. @param scrollView A scrollView subclass informing the delegate. */ - (void)emptyDataSetDidAppear:(UIScrollView *)scrollView; /** Tells the delegate that the empty data set will disappear. @param scrollView A scrollView subclass informing the delegate. */ - (void)emptyDataSetWillDisappear:(UIScrollView *)scrollView; /** Tells the delegate that the empty data set did disappear. @param scrollView A scrollView subclass informing the delegate. */ - (void)emptyDataSetDidDisappear:(UIScrollView *)scrollView; @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/EmptyDataSet/GzwTableViewLoading/UIScrollView+EmptyDataSet.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
2,046
```objective-c // // UITableView+Gzw.m // // // Created by sky33 on 16/1/12. // #import "UITableView+Gzw.h" #import <objc/runtime.h> @implementation UITableView (Gzw) static const BOOL loadingKey; static const char loadedImageNameKey; static const char descriptionTextKey; static const char buttonTextKey; static const char buttonNormalColorKey; static const char buttonHighlightColorKey; static const CGFloat dataVerticalOffsetKey; id (^block)(); ////load //// //+ (void)load{ // // // static dispatch_once_t onceToken; // dispatch_once(&onceToken, ^{ // // //viewControllerselector // SEL systemSel = @selector(initWithFrame:style:); // //selector // SEL swizzSel = @selector(swiz_init); // //Method // Method systemMethod = class_getInstanceMethod([self class], systemSel); // Method swizzMethod = class_getInstanceMethod([self class], swizzSel); // // // // BOOL isAdd = class_addMethod(self, systemSel, method_getImplementation(swizzMethod), method_getTypeEncoding(swizzMethod)); // if (isAdd) { // // // // // class_replaceMethod(self, swizzSel, method_getImplementation(systemMethod), method_getTypeEncoding(systemMethod)); // }else{ // // // method_exchangeImplementations(systemMethod, swizzMethod); // } // }); //} // //- (void)swiz_init{ // // // // // NSLog(@"swizzle"); // // [self swiz_init]; // //} #pragma mark set Mettod -(void)setLoading:(BOOL)loading { if (self.loading == loading) { return; } // &loadingKeykeykey objc_setAssociatedObject(self, &loadingKey, @(loading), OBJC_ASSOCIATION_ASSIGN); // // if (loading == YES) {// self.emptyDataSetSource = self; self.emptyDataSetDelegate = self; [self reloadEmptyDataSet]; // } // if (loading == NO) { // [self reloadEmptyDataSet]; // }else { // __weak __typeof(&*self)weakSelf = self; // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // if (loading) { // if (weakSelf.emptyDataSetVisible) { //// [weakSelf reloadData]; // weakSelf.loading = NO; // } // } // }); // } } -(void)setLoadingClick:(void (^)())loadingClick { objc_setAssociatedObject(self, &block, loadingClick, OBJC_ASSOCIATION_COPY_NONATOMIC); } -(void)setLoadedImageName:(NSString *)loadedImageName { objc_setAssociatedObject(self, &loadedImageNameKey, loadedImageName, OBJC_ASSOCIATION_COPY_NONATOMIC); } -(void)setDataVerticalOffset:(CGFloat)dataVerticalOffset { objc_setAssociatedObject(self, &dataVerticalOffsetKey,@(dataVerticalOffset),OBJC_ASSOCIATION_RETAIN);// RETAIN } -(void)setDescriptionText:(NSString *)descriptionText { objc_setAssociatedObject(self, &descriptionTextKey, descriptionText, OBJC_ASSOCIATION_COPY_NONATOMIC); } -(void)setButtonText:(NSString *)buttonText { objc_setAssociatedObject(self, &buttonTextKey, buttonText, OBJC_ASSOCIATION_COPY_NONATOMIC); } -(void)setButtonNormalColor:(UIColor *)buttonNormalColor { objc_setAssociatedObject(self, &buttonNormalColorKey, buttonNormalColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -(void)setButtonHighlightColor:(UIColor *)buttonHighlightColor { objc_setAssociatedObject(self, &buttonHighlightColorKey, buttonHighlightColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -(void)gzwLoading:(loadingBlock)block { if (self.loadingClick) { block = self.loadingClick; } self.loadingClick = block; } #pragma mark get Mettod -(BOOL)loading { // id tmp = objc_getAssociatedObject(self, &loadingKey); NSNumber *number = tmp; return number.unsignedIntegerValue; } -(void (^)())loadingClick { return objc_getAssociatedObject(self, &block); } -(NSString *)loadedImageName { return objc_getAssociatedObject(self, &loadedImageNameKey); } -(CGFloat)dataVerticalOffset { id temp = objc_getAssociatedObject(self, &dataVerticalOffsetKey); NSNumber *number = temp; return number.floatValue; } -(NSString *)descriptionText { return objc_getAssociatedObject(self, &descriptionTextKey); } -(NSString *)buttonText { return objc_getAssociatedObject(self, &buttonTextKey); } -(UIColor *)buttonNormalColor { return objc_getAssociatedObject(self, &buttonNormalColorKey); } -(UIColor *)buttonHighlightColor { return objc_getAssociatedObject(self, &buttonHighlightColorKey); } #pragma mark - DZNEmptyDataSetSource // view - (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView { if (self.loading) { UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; [activityView startAnimating]; return activityView; }else { return nil; } } // - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView { if (self.loading) { return nil; } else { NSString *imageName = @"placeholder_fancy"; if (self.loadedImageName) { imageName = self.loadedImageName; } return [UIImage imageNamed:imageName]; } } // title //- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView //{ // if (self.loading) { // return nil; // }else { // // NSString *text = @""; // // NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new]; // paragraph.lineBreakMode = NSLineBreakByWordWrapping; // paragraph.alignment = NSTextAlignmentCenter; // // NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], // NSForegroundColorAttributeName: [UIColor lightGrayColor], // NSParagraphStyleAttributeName: paragraph}; // // return [[NSAttributedString alloc] initWithString:text attributes:attributes]; // } //} // - (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView { if (self.loading) { return nil; }else { NSString *text = @""; if (self.descriptionText) { text = self.descriptionText; } NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new]; paragraph.lineBreakMode = NSLineBreakByWordWrapping; paragraph.alignment = NSTextAlignmentCenter; NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName: [UIColor lightGrayColor], NSParagraphStyleAttributeName: paragraph}; return [[NSAttributedString alloc] initWithString:text attributes:attributes]; } } // - (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state { if (self.loading) { return nil; }else { UIColor *textColor = nil; // UIColor *colorOne = [UIColor colorWithRed:253/255.0f green:120/255.0f blue:76/255.0f alpha:1]; UIColor *colorTow = [UIColor colorWithRed:247/255.0f green:188/255.0f blue:169/255.0f alpha:1]; // colorOne = self.buttonNormalColor ? self.buttonNormalColor : colorOne; colorTow = self.buttonHighlightColor ? self.buttonHighlightColor : colorTow; textColor = state == UIControlStateNormal ? colorOne : colorTow; NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:16.0f], NSForegroundColorAttributeName: textColor}; return [[NSAttributedString alloc] initWithString:self.buttonText ? self.buttonText : @"" attributes:attributes]; } } // - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView { if (self.dataVerticalOffset != 0) { return self.dataVerticalOffset; } return 0.0; } #pragma mark - DZNEmptyDataSetDelegate Methods // :YES - (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView { return YES; } // :YES - (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView { // return !self.loading; } // :YES - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView { return YES; } // :NO - (BOOL)emptyDataSetShouldAnimateImageView:(UIScrollView *)scrollView { return YES; } // view - (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view { // // if (self.loadingClick) { // self.loadingClick(); // [self reloadEmptyDataSet]; // } } // - (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button { if (self.loadingClick) { self.loadingClick(); [self reloadEmptyDataSet]; } } @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/EmptyDataSet/GzwTableViewLoading/UITableView+Gzw.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
2,020
```objective-c #import "UITableView+Gzw.h"// ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/EmptyDataSet/GzwTableViewLoading/GzwTableViewLoading.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
11
```objective-c // // UITableView+Gzw.h // // // Created by sky33 on 16/1/12. // tableView #import <UIKit/UIKit.h> #import "UIScrollView+EmptyDataSet.h" typedef void (^loadingBlock)(); @interface UITableView (Gzw)<DZNEmptyDataSetSource, DZNEmptyDataSetDelegate> /** * YES: or NO: * PS:YES()NO() */ @property (nonatomic, assign)BOOL loading; /** * (loading = NO) * PS: */ @property (nonatomic, copy)NSString *loadedImageName; @property (nonatomic, copy)NSString *descriptionText;// /** * */ @property (nonatomic, copy)NSString *buttonText; @property (nonatomic,strong) UIColor *buttonNormalColor;// Normal @property (nonatomic,strong) UIColor *buttonHighlightColor;// Highlight /** * * PS:tableView,(0) */ @property (nonatomic, assign)CGFloat dataVerticalOffset; @property(nonatomic,copy)loadingBlock loadingClick;// block /** * loadingClick * * @param block */ -(void)gzwLoading:(loadingBlock)block; @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/EmptyDataSet/GzwTableViewLoading/UITableView+Gzw.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
231
```objective-c #import "UIImage+CJZ.h" @implementation UIImage (CJZ) + (UIImage *)resizedImageWithName:(NSString *)name { return [self resizedImageWithName:name left:0.5 top:0.5]; } + (UIImage *)resizedImageWithName:(NSString *)name left:(CGFloat)left top:(CGFloat)top { UIImage *image = [UIImage imageNamed:name]; return [image stretchableImageWithLeftCapWidth:image.size.width * left topCapHeight:image.size.height * top]; } + (instancetype)circleImageWithName:(NSString *)name borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor { // 1. UIImage *oldImage = [UIImage imageNamed:name]; // 2. CGFloat imageW = oldImage.size.width + 2 * borderWidth; CGFloat imageH = oldImage.size.height + 2 * borderWidth; CGSize imageSize = CGSizeMake(imageW, imageH); UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0); // 3. CGContextRef ctx = UIGraphicsGetCurrentContext(); // 4.() [borderColor set]; CGFloat bigRadius = imageW * 0.5; // CGFloat centerX = bigRadius; // CGFloat centerY = bigRadius; CGContextAddArc(ctx, centerX, centerY, bigRadius, 0, M_PI * 2, 0); CGContextFillPath(ctx); // // 5. CGFloat smallRadius = bigRadius - borderWidth; CGContextAddArc(ctx, centerX, centerY, smallRadius, 0, M_PI * 2, 0); // () CGContextClip(ctx); // 6. [oldImage drawInRect:CGRectMake(borderWidth, borderWidth, oldImage.size.width, oldImage.size.height)]; // 7. UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); // 8. UIGraphicsEndImageContext(); return newImage; } + (instancetype)circleImageWithImage:(UIImage *)image borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor { // 1. UIImage *oldImage = image; // 2. CGFloat imageW = oldImage.size.width + 2 * borderWidth; CGFloat imageH = oldImage.size.height + 2 * borderWidth; CGSize imageSize = CGSizeMake(imageW, imageH); UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0); // 3. CGContextRef ctx = UIGraphicsGetCurrentContext(); // 4.() [borderColor set]; CGFloat bigRadius = imageW * 0.5; // CGFloat centerX = bigRadius; // CGFloat centerY = bigRadius; CGContextAddArc(ctx, centerX, centerY, bigRadius, 0, M_PI * 2, 0); CGContextFillPath(ctx); // // 5. CGFloat smallRadius = bigRadius - borderWidth; CGContextAddArc(ctx, centerX, centerY, smallRadius, 0, M_PI * 2, 0); // () CGContextClip(ctx); // 6. [oldImage drawInRect:CGRectMake(borderWidth, borderWidth, oldImage.size.width, oldImage.size.height)]; // 7. UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); // 8. UIGraphicsEndImageContext(); return newImage; } @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/Image/UIImage+CJZ.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
729
```objective-c #import <UIKit/UIKit.h> @interface UIImage (CJZ) /** * */ + (UIImage *)resizedImageWithName:(NSString *)name; + (UIImage *)resizedImageWithName:(NSString *)name left:(CGFloat)left top:(CGFloat)top; + (instancetype)circleImageWithName:(NSString *)name borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor; + (instancetype)circleImageWithImage:(UIImage *)image borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor; @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/Image/UIImage+CJZ.h
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
106
```objective-c // // YFImageCategoryViewController.m // BigShow1949 // // Created by zhht01 on 16/4/1. // #import "YFImageCategoryViewController.h" #import "UIImage+EXtension.h" #import "UIImage+CJZ.h" @interface YFImageCategoryViewController () @end @implementation YFImageCategoryViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; // // // UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(10, 100, 50, 50)]; // [btn setBackgroundImage:[UIImage imageWithColor:[UIColor redColor]] forState:UIControlStateNormal]; // [self.view addSubview:btn]; // // // // UIImageView *imgView2 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 160, 50, 50)]; // imgView2.backgroundColor = [UIColor lightGrayColor]; // imgView2.image = [UIImage imageWithColor:[UIColor blueColor] size:CGSizeMake(30, 30)]; // [self.view addSubview:imgView2]; // // // // UIImageView *imgView3 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 220, 100, 100)]; // imgView3.backgroundColor = [UIColor lightGrayColor]; // imgView3.image = [UIImage imageNamed:@"SenderAppNodeBkg_HL"]; // [self.view addSubview:imgView3]; // // UIImageView *imgView4 = [[UIImageView alloc] initWithFrame:CGRectMake(120, 220, 100, 100)]; // imgView4.backgroundColor = [UIColor lightGrayColor]; // imgView4.image = [UIImage stretchImageWithName:@"SenderAppNodeBkg_HL"]; // [self.view addSubview:imgView4]; // // // // // UIImageView *imgView5 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 330, 50, 50)]; // imgView5.backgroundColor = [UIColor lightGrayColor]; // imgView5.image = [UIImage imageNamed:@"bt_star_b"]; // [self.view addSubview:imgView5]; // // UIImageView *imgView6 = [[UIImageView alloc] initWithFrame:CGRectMake(70, 330, 50, 50)]; // imgView6.backgroundColor = [UIColor blueColor]; // imgView6.image = [UIImage circleImage:[UIImage imageNamed:@"bt_star_b"] withInset:10]; // [self.view addSubview:imgView6]; UIImageView *imgView7 = [[UIImageView alloc] initWithFrame:CGRectMake(130, 330, 50, 50)]; imgView7.backgroundColor = [UIColor lightGrayColor]; // imgView7.image = [UIImage circleImageWithName:@"ReceiverTextNodeBkg"]; UIImage *img = [UIImage imageNamed:@"weizhifu"]; imgView7.image = [UIImage circleImageWithImage:img borderWidth:2 borderColor:[UIColor redColor]]; [self.view addSubview:imgView7]; // circleImageWithImage // circleImage } @end ```
/content/code_sandbox/BigShow1949/Classes/11 - Tools(常用工具)/Image/YFImageCategoryViewController.m
objective-c
2016-05-05T08:19:43
2024-08-07T09:29:21
BigShow1949
BigShow1949/BigShow1949
1,121
649