MTAlertView.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // MTAlertView.m
  3. // FunnyFish
  4. //
  5. // Created by Simon on 2020/9/27.
  6. // Copyright © 2020 Linchng Wang. All rights reserved.
  7. //
  8. #import "MTAlertView.h"
  9. @interface MTAlertView ()
  10. @property (weak, nonatomic) IBOutlet UIView *centerView;
  11. @end
  12. @implementation MTAlertView
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. self = [[[NSBundle mainBundle] loadNibNamed:@"MTAlertView" owner:self options:nil] lastObject];
  17. if (self) {
  18. self.frame = frame;
  19. [self setupViews];
  20. }
  21. return self;
  22. }
  23. -(void)setupViews{
  24. [self.centerView mt_yuanjiao:kNumFrom375(14)];
  25. [[self.leftBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
  26. [self removeFromSuperview];
  27. if (self.leftBlock) {
  28. self.leftBlock();
  29. }
  30. }];
  31. [[self.rightBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
  32. [self removeFromSuperview];
  33. if (self.rightBlock) {
  34. self.rightBlock();
  35. }
  36. }];
  37. }
  38. @end