PermissionGuidePopupView.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // PermissionGuidePopupView.m
  3. // OneCable
  4. //
  5. // Created by ncomz on 2017. 7. 3..
  6. // Copyright © 2017년 ntels. All rights reserved.
  7. //
  8. #import "PermissionGuidePopupView.h"
  9. @interface PermissionGuidePopupView ()
  10. @property (strong, nonatomic) void (^popupShowComplition)() ;
  11. @property (strong, nonatomic) void (^popupDismissComplition)(NSInteger result, id data) ;
  12. @end
  13. @implementation PermissionGuidePopupView
  14. - (void)viewDidLoad {
  15. [super viewDidLoad] ;
  16. [self initUI];
  17. }
  18. - (void)presentWithData:(id)data owner:(UIViewController *)owner shown:(void (^)())popupShowComplition dismissed:(void (^)(NSInteger result, id data))popupDismissComplition {
  19. _data = data ;
  20. _popupShowComplition = popupShowComplition ;
  21. _popupDismissComplition = popupDismissComplition ;
  22. [owner presentViewController:self animated:NO completion:^{
  23. if( _popupShowComplition ) {
  24. _popupShowComplition() ;
  25. }
  26. }];
  27. }
  28. - (void)dismissWithResult:(NSInteger)result data:(id)data {
  29. [self dismissViewControllerAnimated:NO completion:^{
  30. if( _popupDismissComplition ) {
  31. _popupDismissComplition(result, data) ;
  32. }
  33. }] ;
  34. }
  35. - (void)initUI {
  36. //라운드 이미지 늘려주기
  37. [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  38. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  39. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  40. [self checkChangeHeightWithLable:_lblDescNecessary
  41. constHeight:_constLblDescNecessaryHeight];
  42. [self checkChangeHeightWithLable:_lblDescOptions
  43. constHeight:_constLblDescOptionsHeight];
  44. }
  45. //디바이스 가로 사이즈에 따라 줄 바꿈이 일어날 수 있다.
  46. - (void)checkChangeHeightWithLable:(UILabel*)label
  47. constHeight:(NSLayoutConstraint*)constHeight {
  48. float width = MainScreen.bounds.size.width - 50.f - 40.f;
  49. CGSize size = [label sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)];
  50. constHeight.constant = (size.height / 20.f + 1) * 20;
  51. }
  52. #pragma mark - user action
  53. //확인버튼 클릭
  54. - (IBAction)confirm:(id)sender {
  55. [self dismissWithResult:1 data:nil];
  56. }
  57. @end