ZCBaseVC.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // ZCBaseVC.m
  3. // HuaKaiChat
  4. //
  5. // Created by 张灿 on 2017/6/27.
  6. // Copyright © 2017年 huakai. All rights reserved.
  7. //
  8. #import "ZCBaseVC.h"
  9. @interface ZCBaseVC ()
  10. @property (nonatomic,strong)UILabel *label;
  11. @end
  12. @implementation ZCBaseVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.view.backgroundColor = LZFAFAFCColor;
  16. //从屏幕左上角作为(0.0)不包括导航栏的高度
  17. self.automaticallyAdjustsScrollViewInsets = NO;
  18. self.extendedLayoutIncludesOpaqueBars = YES;
  19. if (@available(iOS 11.0, *)) {
  20. UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  21. }else {
  22. self.automaticallyAdjustsScrollViewInsets = NO;
  23. }
  24. // 禁用返回手势
  25. if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
  26. self.navigationController.interactivePopGestureRecognizer.enabled = NO;
  27. }
  28. self.sx_disableInteractivePop = NO;
  29. }
  30. -(void)viewWillAppear:(BOOL)animated{
  31. [super viewWillAppear:animated];
  32. [UMengRecordTool umengEnterViewWithName:NSStringFromClass(self.class)];
  33. }
  34. - (void)viewDidDisappear:(BOOL)animated {
  35. [super viewDidDisappear:animated];
  36. [UMengRecordTool umengOutViewWithName:NSStringFromClass(self.class)];
  37. #ifdef DEBUG
  38. NSLog(@"*******ViewController did Disappear = %@", NSStringFromClass([self class]));
  39. #endif
  40. }
  41. - (void)viewDidAppear:(BOOL)animated{
  42. [super viewDidAppear:animated];
  43. #ifdef DEBUG
  44. NSLog(@"*******ViewController did appear = %@", NSStringFromClass([self class]));
  45. #endif
  46. }
  47. - (void)dealloc {
  48. #ifdef DEBUG
  49. NSLog(@"*******ViewController dealloc = %@", NSStringFromClass([self class]));
  50. #endif
  51. [OCNotificationCenter removeObserver:self];
  52. }
  53. -(BOOL)prefersStatusBarHidden
  54. {
  55. return NO;
  56. }
  57. - (UIStatusBarStyle)preferredStatusBarStyle{
  58. return UIStatusBarStyleDefault;
  59. }
  60. - (void)pushEffectPresentToVC:(UIViewController*)vc{
  61. CATransition *transition = [CATransition animation];
  62. transition.duration = 0.4;
  63. transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
  64. transition.type = kCATransitionPush;
  65. transition.subtype = kCATransitionFromTop;
  66. [self.navigationController.view.layer addAnimation:transition forKey:nil];
  67. [self.navigationController pushViewController:vc animated:NO ];
  68. }
  69. - (void)popEffectDismiss{
  70. CATransition *transition = [CATransition animation];
  71. transition.duration = 0.4;
  72. transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
  73. transition.type = kCATransitionPush;
  74. transition.subtype = kCATransitionFromBottom;
  75. [self.navigationController.view.layer addAnimation:transition forKey:nil];
  76. [self.navigationController popViewControllerAnimated:NO];
  77. }
  78. - (void)popEffectDismissWithIndex:(NSInteger)index{
  79. CATransition *transition = [CATransition animation];
  80. transition.duration = 0.4;
  81. transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
  82. transition.type = kCATransitionPush;
  83. transition.subtype = kCATransitionFromBottom;
  84. [self.navigationController.view.layer addAnimation:transition forKey:nil];
  85. self.navigationController.navigationBarHidden = NO;
  86. [self.navigationController popToViewController:self.navigationController.childViewControllers[index] animated:NO];
  87. }
  88. @end