BGBaseView.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // BGBaseView.m
  3. // BuguLive
  4. //
  5. // Created by xfg on 2017/6/17.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGBaseView.h"
  9. #import "BGNoContentView.h"
  10. @implementation BGBaseView
  11. - (NetHttpsManager *)httpsManager
  12. {
  13. if (!_httpsManager)
  14. {
  15. _httpsManager = [NetHttpsManager manager];
  16. }
  17. return _httpsManager;
  18. }
  19. - (GlobalVariables *)BuguLive
  20. {
  21. if (!_BuguLive)
  22. {
  23. _BuguLive = [GlobalVariables sharedInstance];
  24. }
  25. return _BuguLive;
  26. }
  27. #pragma mark - HUD
  28. - (MBProgressHUD *)proHud
  29. {
  30. if (!_proHud)
  31. {
  32. _proHud = [MBProgressHUD showHUDAddedTo:self animated:YES];
  33. _proHud.mode = MBProgressHUDModeIndeterminate;
  34. }
  35. return _proHud;
  36. }
  37. - (void)hideMyHud
  38. {
  39. if (_proHud)
  40. {
  41. [_proHud hideAnimated:YES];
  42. _proHud = nil;
  43. }
  44. }
  45. - (void)showMyHud
  46. {
  47. [self.proHud showAnimated:YES];
  48. }
  49. - (void)showNoContentViewOnView:(UIView *)view
  50. {
  51. if (!self.noContentView)
  52. {
  53. self.noContentView = [BGNoContentView noContentWithFrame:CGRectMake(0, 0, 150, 175)];
  54. }
  55. self.noContentView.center = CGPointMake(view.frame.size.width/2,view.frame.size.height/2);
  56. [view addSubview:self.noContentView];
  57. }
  58. - (void)hideNoContentViewOnView:(UIView *)view
  59. {
  60. [self.noContentView removeFromSuperview];
  61. self.noContentView = nil;
  62. }
  63. - (void)show:(UIView *)superView{
  64. // [self requestWardData];
  65. [superView addSubview:self.shadowViews];
  66. [superView addSubview:self];
  67. [UIView animateWithDuration:0.25 animations:^{
  68. // self.center = CGPointMake(kScreenW / 2, kScreenH / 2);
  69. self.bottom = kScreenH;
  70. self.shadowViews.alpha = 1;
  71. }];
  72. }
  73. - (void)show:(UIView *)superView frame:(CGRect)frame{
  74. [superView addSubview:self.shadowViews];
  75. [superView addSubview:self];
  76. [UIView animateWithDuration:0.25 animations:^{
  77. // self.center = CGPointMake(kScreenW / 2, kScreenH / 2);
  78. self.frame = frame;
  79. self.shadowViews.alpha = 1;
  80. }];
  81. }
  82. - (void)hide{
  83. if (self.clickShadowBlock) {
  84. self.clickShadowBlock(YES);
  85. // return;
  86. }
  87. [UIView animateWithDuration:0.25 animations:^{
  88. // self.frame = CGRectMake(0, kScreenH, self.width, self.height);
  89. // self.shadowViews.alpha = 0;
  90. } completion:^(BOOL finished) {
  91. [self removeFromSuperview];
  92. [self.shadowViews removeFromSuperview];
  93. }];
  94. }
  95. - (UIView *)shadowViews{
  96. if (!_shadowViews) {
  97. _shadowViews = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
  98. _shadowViews.backgroundColor = [kBlackColor colorWithAlphaComponent:0.5];
  99. _shadowViews.alpha = 0;
  100. _shadowViews.userInteractionEnabled = YES;
  101. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hide)];
  102. [_shadowViews addGestureRecognizer:tap];
  103. }
  104. return _shadowViews;
  105. }
  106. @end