// // PermissionGuidePopupView.m // OneCable // // Created by ncomz on 2017. 7. 3.. // Copyright © 2017년 ntels. All rights reserved. // #import "PermissionGuidePopupView.h" @interface PermissionGuidePopupView () @property (strong, nonatomic) void (^popupShowComplition)() ; @property (strong, nonatomic) void (^popupDismissComplition)(NSInteger result, id data) ; @end @implementation PermissionGuidePopupView - (void)viewDidLoad { [super viewDidLoad] ; [self initUI]; } - (void)presentWithData:(id)data owner:(UIViewController *)owner shown:(void (^)())popupShowComplition dismissed:(void (^)(NSInteger result, id data))popupDismissComplition { _data = data ; _popupShowComplition = popupShowComplition ; _popupDismissComplition = popupDismissComplition ; [owner presentViewController:self animated:NO completion:^{ if( _popupShowComplition ) { _popupShowComplition() ; } }]; } - (void)dismissWithResult:(NSInteger)result data:(id)data { [self dismissViewControllerAnimated:NO completion:^{ if( _popupDismissComplition ) { _popupDismissComplition(result, data) ; } }] ; } - (void)initUI { //라운드 이미지 늘려주기 [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)]; [self checkChangeHeightWithLable:_lblDescNecessary constHeight:_constLblDescNecessaryHeight]; [self checkChangeHeightWithLable:_lblDescOptions constHeight:_constLblDescOptionsHeight]; } //디바이스 가로 사이즈에 따라 줄 바꿈이 일어날 수 있다. - (void)checkChangeHeightWithLable:(UILabel*)label constHeight:(NSLayoutConstraint*)constHeight { float width = MainScreen.bounds.size.width - 50.f - 40.f; CGSize size = [label sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)]; constHeight.constant = (size.height / 20.f + 1) * 20; } #pragma mark - user action //확인버튼 클릭 - (IBAction)confirm:(id)sender { [self dismissWithResult:1 data:nil]; } @end