ShowPhotoCameraAlertView.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // ShowPhotoCameraAlertView.m
  3. // smartRhino
  4. //
  5. // Created by armin on 2019/11/1.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "ShowPhotoCameraAlertView.h"
  9. @interface ShowPhotoCameraAlertView ()
  10. @property (copy, nonatomic) void(^confirmBlock)(ShowPhotoCameraType type);
  11. @property (copy, nonatomic) void(^cancelBlock)(void);
  12. @property (strong,nonatomic) IBOutlet NSLayoutConstraint *bottomH;
  13. @end
  14. @implementation ShowPhotoCameraAlertView
  15. static UINib *ViewNib = nil;
  16. + (instancetype)selectView{
  17. if (ViewNib == nil) {
  18. ViewNib = [UINib nibWithNibName:@"ShowPhotoCameraAlertView" bundle:nil];
  19. }
  20. ShowPhotoCameraAlertView *alert = [[ViewNib instantiateWithOwner:nil options:nil] lastObject];
  21. return alert;
  22. }
  23. /**
  24. * 弹出选择照片/相机alert
  25. */
  26. +(instancetype)initShowPhotoCameraAlertViewConfirm:(void(^)(ShowPhotoCameraType type))confirmBlock
  27. cancle:(void(^)(void))cancleBlock{
  28. ShowPhotoCameraAlertView *alert = [self selectView];
  29. [alert setFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  30. alert.bottomH.constant = 143 + kiphoneXBootomHeight;
  31. [alert setStatusBarStyle:UIStatusBarStyleDefault];
  32. [alert setGesture:YES];
  33. [alert setConfirmBlock:confirmBlock];
  34. [alert setCancelBlock:cancleBlock];
  35. return alert;
  36. }
  37. -(IBAction)userDidBackClickAction:(id)sender{
  38. [self dismissWithAnimation:kAlertAnimationBottom];
  39. if(self.cancelBlock){
  40. self.cancelBlock();
  41. }
  42. }
  43. -(IBAction)userDidPhotoClickAction:(id)sender{
  44. [self dismissWithAnimation:kAlertAnimationBottom];
  45. if(self.confirmBlock){
  46. self.confirmBlock(ShowPhotoCameraType1);
  47. }
  48. }
  49. -(IBAction)userDidCameraClickAction:(id)sender{
  50. [self dismissWithAnimation:kAlertAnimationBottom];
  51. if(self.confirmBlock){
  52. self.confirmBlock(ShowPhotoCameraType2);
  53. }
  54. }
  55. @end