SharePopViewController.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // ShareViewController.m
  3. // KeleAppProject
  4. //
  5. // Created by 熊竹 on 2018/3/5.
  6. // Copyright © 2018年 Cen Zhou. All rights reserved.
  7. //
  8. #import "SharePopViewController.h"
  9. @interface SharePopViewController ()
  10. @property(weak, nonatomic) IBOutlet UIView *contentView;
  11. @property(weak, nonatomic) IBOutlet UIImageView *shareWechat;
  12. @property(weak, nonatomic) IBOutlet UIImageView *shareTimeline;
  13. @end
  14. @implementation SharePopViewController
  15. - (instancetype)init {
  16. self = [super init];
  17. if (self) {
  18. self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  19. self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
  20. self.view.userInteractionEnabled = YES;
  21. }
  22. return self;
  23. }
  24. - (instancetype)initWithCoder:(NSCoder *)coder {
  25. self = [super initWithCoder:coder];
  26. if (self) {
  27. self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  28. self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
  29. self.view.userInteractionEnabled = YES;
  30. }
  31. return self;
  32. }
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. self.contentView.transform = CGAffineTransformMakeTranslation(0, 164);
  36. self.shareWechat.userInteractionEnabled = YES;
  37. self.shareTimeline.userInteractionEnabled = YES;
  38. }
  39. - (void)viewWillAppear:(BOOL)animated {
  40. [super viewWillAppear:animated];
  41. [UIView animateWithDuration:0.2
  42. delay:0
  43. options:UIViewAnimationOptionCurveEaseOut
  44. animations:^{
  45. self.contentView.transform = CGAffineTransformMakeTranslation(0, 0);
  46. self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.2];
  47. }
  48. completion:nil];
  49. }
  50. - (IBAction)cancel:(id)sender {
  51. [self dismiss];
  52. }
  53. - (IBAction)tapItem:(id)sender {
  54. [self dismiss];
  55. if (((UITapGestureRecognizer *) sender).view.tag == 1) {
  56. if (self.delegate) {
  57. [self.delegate shareWxSession];
  58. }
  59. } else if (((UITapGestureRecognizer *) sender).view.tag == 2) {
  60. if (self.delegate) {
  61. [self.delegate shareWxTimeline];
  62. }
  63. }
  64. }
  65. - (void)dismiss {
  66. [UIView animateWithDuration:0.2
  67. delay:0
  68. options:UIViewAnimationOptionCurveEaseInOut
  69. animations:^{
  70. self.contentView.transform = CGAffineTransformMakeTranslation(0, 164);
  71. self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
  72. }
  73. completion:^(BOOL finished) {
  74. [self dismissViewControllerAnimated:NO completion:nil];
  75. }];
  76. }
  77. /*
  78. #pragma mark - Navigation
  79. // In a storyboard-based application, you will often want to do a little preparation before navigation
  80. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  81. // Get the new view controller using [segue destinationViewController].
  82. // Pass the selected object to the new view controller.
  83. }
  84. */
  85. @end