重庆迈尖科技有限公司
2018-06-28 093669a250cd8ba538c3ff843fc776c37b869dca
代码整理-4
13个文件已修改
2119 ■■■■ 已修改文件
MIduo/数据/lib/HXEasyCustomShare/HXEasyCustomShareView.m 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/KLCPopup/KLCPopup.h 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/KLCPopup/KLCPopup.m 1751 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/LBXScan/LBXScanLineAnimation.m 87 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/LBXScan/LBXScanNative.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/LBXScan/LBXScanNative.m 107 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/LBXScan/LBXScanNetAnimation.m 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/LBXScan/LBXScanWrapper.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/ScanQRViewController.m 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/ZXingObjC/ZXingObjC/client/ZXCGImageLuminanceSource.m 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/数据/lib/LBXScan/ZXingObjC/ZXingObjC/common/ZXCharacterSetECI.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/界面/我的/LoginViewController.m 84 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/界面/我的/RedPacketDetailViewController.m 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MIduo/Êý¾Ý/lib/HXEasyCustomShare/HXEasyCustomShareView.m
@@ -141,11 +141,11 @@
        }
        
        if (self.boderView) {
            self.boderView.frame = CGRectMake(0, self.boderView.frame.origin.y + self.backView.frame.size.height, _boderView.frame.size.width, _boderView.frame.size.height);
            self.boderView.frame = CGRectMake(0, self.boderView.frame.origin.y + self.backView.frame.size.height, self.boderView.frame.size.width, self.boderView.frame.size.height);
        }
        
        if (_headerView) {
            _headerView.frame = CGRectMake(0, _headerView.frame.origin.y + _backView.frame.size.height, _headerView.frame.size.width, _headerView.frame.size.height);
        if (self.headerView) {
            self.headerView.frame = CGRectMake(0, self.headerView.frame.origin.y + self.backView.frame.size.height, self.headerView.frame.size.width, self.headerView.frame.size.height);
        }
    } completion:^(BOOL finished) {
        if (finished) {
@@ -214,24 +214,24 @@
    
    [UIView animateWithDuration:0.5 animations:^{
        
        if (_cancleButton) {
            _cancleButton.frame = CGRectMake(0, _cancleButton.frame.origin.y - _backView.frame.size.height, _cancleButton.frame.size.width, _cancleButton.frame.size.height);
        if (self.cancleButton) {
            self.cancleButton.frame = CGRectMake(0, self.cancleButton.frame.origin.y - self.backView.frame.size.height, self.cancleButton.frame.size.width, self.cancleButton.frame.size.height);
        }
        
        if (_footerView) {
            _footerView.frame = CGRectMake(0, _footerView.frame.origin.y - _backView.frame.size.height, _footerView.frame.size.width, _footerView.frame.size.height);
        if (self.footerView) {
            self.footerView.frame = CGRectMake(0, self.footerView.frame.origin.y - self.backView.frame.size.height, self.footerView.frame.size.width, self.footerView.frame.size.height);
        }
        
        if (_boderView) {
            _boderView.frame = CGRectMake(0, _boderView.frame.origin.y - _backView.frame.size.height, _boderView.frame.size.width, _boderView.frame.size.height);
        if (self.boderView) {
            self.boderView.frame = CGRectMake(0, self.boderView.frame.origin.y - self.backView.frame.size.height, self.boderView.frame.size.width, self.boderView.frame.size.height);
        }
        
        if (_headerView) {
            _headerView.frame = CGRectMake(0, _headerView.frame.origin.y - _backView.frame.size.height, _headerView.frame.size.width, _headerView.frame.size.height);
        if (self.headerView) {
            self.headerView.frame = CGRectMake(0, self.headerView.frame.origin.y - self.backView.frame.size.height, self.headerView.frame.size.width, self.headerView.frame.size.height);
        }
        
        if (_backView) {
            _backView.frame = CGRectMake(0, self.frame.size.height - _backView.frame.size.height, _backView.frame.size.width, _backView.frame.size.height);
        if (self.backView) {
            self.backView.frame = CGRectMake(0, self.frame.size.height - self.backView.frame.size.height, self.backView.frame.size.width, self.backView.frame.size.height);
        }
        
        UIView *zhezhaoView = (UIView *)[self viewWithTag:100];
MIduo/Êý¾Ý/lib/KLCPopup/KLCPopup.h
@@ -124,13 +124,13 @@
@property (nonatomic, assign) BOOL shouldDismissOnContentTouch;
// Block gets called after show animation finishes. Be sure to use weak reference for popup within the block to avoid retain cycle.
@property (nonatomic, copy) void (^didFinishShowingCompletion)();
@property (nonatomic, copy) void (^didFinishShowingCompletion)(void);
// Block gets called when dismiss animation starts. Be sure to use weak reference for popup within the block to avoid retain cycle.
@property (nonatomic, copy) void (^willStartDismissingCompletion)();
@property (nonatomic, copy) void (^willStartDismissingCompletion)(void);
// Block gets called after dismiss animation finishes. Be sure to use weak reference for popup within the block to avoid retain cycle.
@property (nonatomic, copy) void (^didFinishDismissingCompletion)();
@property (nonatomic, copy) void (^didFinishDismissingCompletion)(void);
// Convenience method for creating popup with default values (mimics UIAlertView).
+ (KLCPopup*)popupWithContentView:(UIView*)contentView;
MIduo/Êý¾Ý/lib/KLCPopup/KLCPopup.m
@@ -27,10 +27,10 @@
static NSInteger const kAnimationOptionCurveIOS7 = (7 << 16);
KLCPopupLayout KLCPopupLayoutMake(KLCPopupHorizontalLayout horizontal, KLCPopupVerticalLayout vertical){
  KLCPopupLayout layout;
  layout.horizontal = horizontal;
  layout.vertical = vertical;
  return layout;
    KLCPopupLayout layout;
    layout.horizontal = horizontal;
    layout.vertical = vertical;
    return layout;
}
const KLCPopupLayout KLCPopupLayoutCenter = { KLCPopupHorizontalLayoutCenter, KLCPopupVerticalLayoutCenter };
@@ -43,14 +43,14 @@
@interface KLCPopup () {
  // views
  UIView* _backgroundView;
  UIView* _containerView;
  // state flags
  BOOL _isBeingShown;
  BOOL _isShowing;
  BOOL _isBeingDismissed;
    // views
    UIView* _backgroundView;
    UIView* _containerView;
    // state flags
    BOOL _isBeingShown;
    BOOL _isShowing;
    BOOL _isBeingDismissed;
}
- (void)updateForInterfaceOrientation;
@@ -72,93 +72,93 @@
- (void)dealloc {
  [NSObject cancelPreviousPerformRequestsWithTarget:self];
  // stop listening to notifications
  [[NSNotificationCenter defaultCenter] removeObserver:self];
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
    // stop listening to notifications
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (id)init {
  return [self initWithFrame:[[UIScreen mainScreen] bounds]];
    return [self initWithFrame:[[UIScreen mainScreen] bounds]];
}
- (id)initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    self.userInteractionEnabled = YES;
    self.backgroundColor = [UIColor clearColor];
        self.alpha = 0;
    self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    self.autoresizesSubviews = YES;
    self.shouldDismissOnBackgroundTouch = YES;
    self.shouldDismissOnContentTouch = NO;
    self.showType = KLCPopupShowTypeShrinkIn;
    self.dismissType = KLCPopupDismissTypeShrinkOut;
    self.maskType = KLCPopupMaskTypeDimmed;
    self.dimmedMaskAlpha = 0.5;
    _isBeingShown = NO;
    _isShowing = NO;
    _isBeingDismissed = NO;
    _backgroundView = [[UIView alloc] init];
    _backgroundView.backgroundColor = [UIColor clearColor];
    _backgroundView.userInteractionEnabled = NO;
    _backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _backgroundView.frame = self.bounds;
    _containerView = [[UIView alloc] init];
    _containerView.autoresizesSubviews = NO;
    _containerView.userInteractionEnabled = YES;
    _containerView.backgroundColor = [UIColor clearColor];
    [self addSubview:_backgroundView];
    [self addSubview:_containerView];
    // register for notifications
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(didChangeStatusBarOrientation:)
                                                 name:UIApplicationDidChangeStatusBarFrameNotification
                                               object:nil];
  }
  return self;
    self = [super initWithFrame:frame];
    if (self) {
        self.userInteractionEnabled = YES;
        self.backgroundColor = [UIColor clearColor];
        self.alpha = 0;
        self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        self.autoresizesSubviews = YES;
        self.shouldDismissOnBackgroundTouch = YES;
        self.shouldDismissOnContentTouch = NO;
        self.showType = KLCPopupShowTypeShrinkIn;
        self.dismissType = KLCPopupDismissTypeShrinkOut;
        self.maskType = KLCPopupMaskTypeDimmed;
        self.dimmedMaskAlpha = 0.5;
        _isBeingShown = NO;
        _isShowing = NO;
        _isBeingDismissed = NO;
        _backgroundView = [[UIView alloc] init];
        _backgroundView.backgroundColor = [UIColor clearColor];
        _backgroundView.userInteractionEnabled = NO;
        _backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        _backgroundView.frame = self.bounds;
        _containerView = [[UIView alloc] init];
        _containerView.autoresizesSubviews = NO;
        _containerView.userInteractionEnabled = YES;
        _containerView.backgroundColor = [UIColor clearColor];
        [self addSubview:_backgroundView];
        [self addSubview:_containerView];
        // register for notifications
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(didChangeStatusBarOrientation:)
                                                     name:UIApplicationDidChangeStatusBarFrameNotification
                                                   object:nil];
    }
    return self;
}
#pragma mark - UIView
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  UIView* hitView = [super hitTest:point withEvent:event];
  if (hitView == self) {
    
    // Try to dismiss if backgroundTouch flag set.
    if (_shouldDismissOnBackgroundTouch) {
      [self dismiss:YES];
    }
    // If no mask, then return nil so touch passes through to underlying views.
    if (_maskType == KLCPopupMaskTypeNone) {
      return nil;
    UIView* hitView = [super hitTest:point withEvent:event];
    if (hitView == self) {
        // Try to dismiss if backgroundTouch flag set.
        if (_shouldDismissOnBackgroundTouch) {
            [self dismiss:YES];
        }
        // If no mask, then return nil so touch passes through to underlying views.
        if (_maskType == KLCPopupMaskTypeNone) {
            return nil;
        } else {
            return hitView;
        }
    } else {
      return hitView;
        // If view is within containerView and contentTouch flag set, then try to hide.
        if ([hitView isDescendantOfView:_containerView]) {
            if (_shouldDismissOnContentTouch) {
                [self dismiss:YES];
            }
        }
        return hitView;
    }
  } else {
    // If view is within containerView and contentTouch flag set, then try to hide.
    if ([hitView isDescendantOfView:_containerView]) {
      if (_shouldDismissOnContentTouch) {
        [self dismiss:YES];
      }
    }
    return hitView;
  }
}
@@ -166,9 +166,9 @@
+ (KLCPopup*)popupWithContentView:(UIView*)contentView
{
  KLCPopup* popup = [[[self class] alloc] init];
  popup.contentView = contentView;
  return popup;
    KLCPopup* popup = [[[self class] alloc] init];
    popup.contentView = contentView;
    return popup;
}
@@ -179,878 +179,881 @@
         dismissOnBackgroundTouch:(BOOL)shouldDismissOnBackgroundTouch
            dismissOnContentTouch:(BOOL)shouldDismissOnContentTouch
{
  KLCPopup* popup = [[[self class] alloc] init];
  popup.contentView = contentView;
  popup.showType = showType;
  popup.dismissType = dismissType;
  popup.maskType = maskType;
  popup.shouldDismissOnBackgroundTouch = shouldDismissOnBackgroundTouch;
  popup.shouldDismissOnContentTouch = shouldDismissOnContentTouch;
  return popup;
    KLCPopup* popup = [[[self class] alloc] init];
    popup.contentView = contentView;
    popup.showType = showType;
    popup.dismissType = dismissType;
    popup.maskType = maskType;
    popup.shouldDismissOnBackgroundTouch = shouldDismissOnBackgroundTouch;
    popup.shouldDismissOnContentTouch = shouldDismissOnContentTouch;
    return popup;
}
+ (void)dismissAllPopups {
  NSArray* windows = [[UIApplication sharedApplication] windows];
  for (UIWindow* window in windows) {
    [window forEachPopupDoBlock:^(KLCPopup *popup) {
      [popup dismiss:NO];
    }];
  }
    NSArray* windows = [[UIApplication sharedApplication] windows];
    for (UIWindow* window in windows) {
        [window forEachPopupDoBlock:^(KLCPopup *popup) {
            [popup dismiss:NO];
        }];
    }
}
#pragma mark - Public
- (void)show {
  [self showWithLayout:KLCPopupLayoutCenter];
    [self showWithLayout:KLCPopupLayoutCenter];
}
- (void)showWithLayout:(KLCPopupLayout)layout {
  [self showWithLayout:layout duration:0.0];
    [self showWithLayout:layout duration:0.0];
}
- (void)showWithDuration:(NSTimeInterval)duration {
  [self showWithLayout:KLCPopupLayoutCenter duration:duration];
    [self showWithLayout:KLCPopupLayoutCenter duration:duration];
}
- (void)showWithLayout:(KLCPopupLayout)layout duration:(NSTimeInterval)duration {
  NSDictionary* parameters = @{@"layout" : [NSValue valueWithKLCPopupLayout:layout],
                               @"duration" : @(duration)};
  [self showWithParameters:parameters];
    NSDictionary* parameters = @{@"layout" : [NSValue valueWithKLCPopupLayout:layout],
                                 @"duration" : @(duration)};
    [self showWithParameters:parameters];
}
- (void)showAtCenter:(CGPoint)center inView:(UIView*)view {
  [self showAtCenter:center inView:view withDuration:0.0];
    [self showAtCenter:center inView:view withDuration:0.0];
}
- (void)showAtCenter:(CGPoint)center inView:(UIView *)view withDuration:(NSTimeInterval)duration {
  NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
  [parameters setValue:[NSValue valueWithCGPoint:center] forKey:@"center"];
  [parameters setValue:@(duration) forKey:@"duration"];
  [parameters setValue:view forKey:@"view"];
  [self showWithParameters:[NSDictionary dictionaryWithDictionary:parameters]];
    NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
    [parameters setValue:[NSValue valueWithCGPoint:center] forKey:@"center"];
    [parameters setValue:@(duration) forKey:@"duration"];
    [parameters setValue:view forKey:@"view"];
    [self showWithParameters:[NSDictionary dictionaryWithDictionary:parameters]];
}
- (void)dismiss:(BOOL)animated {
  if (_isShowing && !_isBeingDismissed) {
    _isBeingShown = NO;
    _isShowing = NO;
    _isBeingDismissed = YES;
    
    // cancel previous dismiss requests (i.e. the dismiss after duration call).
    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(dismiss) object:nil];
    [self willStartDismissing];
    if (self.willStartDismissingCompletion != nil) {
      self.willStartDismissingCompletion();
    }
    dispatch_async( dispatch_get_main_queue(), ^{
      // Animate background if needed
      void (^backgroundAnimationBlock)(void) = ^(void) {
        _backgroundView.alpha = 0.0;
      };
      if (animated && (_showType != KLCPopupShowTypeNone)) {
        // Make fade happen faster than motion. Use linear for fades.
        [UIView animateWithDuration:0.15
                              delay:0
                            options:UIViewAnimationOptionCurveLinear
                         animations:backgroundAnimationBlock
                         completion:NULL];
      } else {
        backgroundAnimationBlock();
      }
      // Setup completion block
      void (^completionBlock)(BOOL) = ^(BOOL finished) {
        [self removeFromSuperview];
    if (_isShowing && !_isBeingDismissed) {
        _isBeingShown = NO;
        _isShowing = NO;
        _isBeingDismissed = NO;
        _isBeingDismissed = YES;
        
        [self didFinishDismissing];
        // cancel previous dismiss requests (i.e. the dismiss after duration call).
        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(dismiss) object:nil];
        
        if (self.didFinishDismissingCompletion != nil) {
          self.didFinishDismissingCompletion();
        [self willStartDismissing];
        if (self.willStartDismissingCompletion != nil) {
            self.willStartDismissingCompletion();
        }
      };
      NSTimeInterval bounce1Duration = 0.13;
      NSTimeInterval bounce2Duration = (bounce1Duration * 2.0);
      // Animate content if needed
      if (animated) {
        switch (_dismissType) {
          case KLCPopupDismissTypeFadeOut: {
            [UIView animateWithDuration:0.15
                                  delay:0
                                options:UIViewAnimationOptionCurveLinear
                             animations:^{
                               _containerView.alpha = 0.0;
                             } completion:completionBlock];
            break;
          }
        dispatch_async( dispatch_get_main_queue(), ^{
            
          case KLCPopupDismissTypeGrowOut: {
            [UIView animateWithDuration:0.15
                                  delay:0
                                options:kAnimationOptionCurveIOS7
                             animations:^{
                               _containerView.alpha = 0.0;
                               _containerView.transform = CGAffineTransformMakeScale(1.1, 1.1);
                             } completion:completionBlock];
            break;
          }
            // Animate background if needed
            void (^backgroundAnimationBlock)(void) = ^(void) {
                self->_backgroundView.alpha = 0.0;
            };
            
          case KLCPopupDismissTypeShrinkOut: {
            [UIView animateWithDuration:0.15
                                  delay:0
                                options:kAnimationOptionCurveIOS7
                             animations:^{
                               _containerView.alpha = 0.0;
                               _containerView.transform = CGAffineTransformMakeScale(0.8, 0.8);
                             } completion:completionBlock];
            break;
          }
            if (animated && (self->_showType != KLCPopupShowTypeNone)) {
                // Make fade happen faster than motion. Use linear for fades.
                [UIView animateWithDuration:0.15
                                      delay:0
                                    options:UIViewAnimationOptionCurveLinear
                                 animations:backgroundAnimationBlock
                                 completion:NULL];
            } else {
                backgroundAnimationBlock();
            }
            
          case KLCPopupDismissTypeSlideOutToTop: {
            [UIView animateWithDuration:0.30
                                  delay:0
                                options:kAnimationOptionCurveIOS7
                             animations:^{
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.y = -CGRectGetHeight(finalFrame);
                               _containerView.frame = finalFrame;
                             }
                             completion:completionBlock];
            break;
          }
            // Setup completion block
            void (^completionBlock)(BOOL) = ^(BOOL finished) {
                [self removeFromSuperview];
                self->_isBeingShown = NO;
                self->_isShowing = NO;
                self->_isBeingDismissed = NO;
                [self didFinishDismissing];
                if (self.didFinishDismissingCompletion != nil) {
                    self.didFinishDismissingCompletion();
                }
            };
            
          case KLCPopupDismissTypeSlideOutToBottom: {
            [UIView animateWithDuration:0.30
                                  delay:0
                                options:kAnimationOptionCurveIOS7
                             animations:^{
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.y = CGRectGetHeight(self.bounds);
                               _containerView.frame = finalFrame;
                             }
                             completion:completionBlock];
            break;
          }
            NSTimeInterval bounce1Duration = 0.13;
            NSTimeInterval bounce2Duration = (bounce1Duration * 2.0);
            
          case KLCPopupDismissTypeSlideOutToLeft: {
            [UIView animateWithDuration:0.30
                                  delay:0
                                options:kAnimationOptionCurveIOS7
                             animations:^{
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.x = -CGRectGetWidth(finalFrame);
                               _containerView.frame = finalFrame;
                             }
                             completion:completionBlock];
            break;
          }
            // Animate content if needed
            if (animated) {
                switch (self.dismissType) {
                    case KLCPopupDismissTypeFadeOut: {
                        [UIView animateWithDuration:0.15
                                              delay:0
                                            options:UIViewAnimationOptionCurveLinear
                                         animations:^{
                                             self->_containerView.alpha = 0.0;
                                         } completion:completionBlock];
                        break;
                    }
                    case KLCPopupDismissTypeGrowOut: {
                        [UIView animateWithDuration:0.15
                                              delay:0
                                            options:kAnimationOptionCurveIOS7
                                         animations:^{
                                             self->_containerView.alpha = 0.0;
                                             self->_containerView.transform = CGAffineTransformMakeScale(1.1, 1.1);
                                         } completion:completionBlock];
                        break;
                    }
                    case KLCPopupDismissTypeShrinkOut: {
                        [UIView animateWithDuration:0.15
                                              delay:0
                                            options:kAnimationOptionCurveIOS7
                                         animations:^{
                                             self->_containerView.alpha = 0.0;
                                             self->_containerView.transform = CGAffineTransformMakeScale(0.8, 0.8);
                                         } completion:completionBlock];
                        break;
                    }
                    case KLCPopupDismissTypeSlideOutToTop: {
                        [UIView animateWithDuration:0.30
                                              delay:0
                                            options:kAnimationOptionCurveIOS7
                                         animations:^{
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.y = -CGRectGetHeight(finalFrame);
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:completionBlock];
                        break;
                    }
                    case KLCPopupDismissTypeSlideOutToBottom: {
                        [UIView animateWithDuration:0.30
                                              delay:0
                                            options:kAnimationOptionCurveIOS7
                                         animations:^{
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.y = CGRectGetHeight(self.bounds);
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:completionBlock];
                        break;
                    }
                    case KLCPopupDismissTypeSlideOutToLeft: {
                        [UIView animateWithDuration:0.30
                                              delay:0
                                            options:kAnimationOptionCurveIOS7
                                         animations:^{
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.x = -CGRectGetWidth(finalFrame);
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:completionBlock];
                        break;
                    }
                    case KLCPopupDismissTypeSlideOutToRight: {
                        [UIView animateWithDuration:0.30
                                              delay:0
                                            options:kAnimationOptionCurveIOS7
                                         animations:^{
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.x = CGRectGetWidth(self.bounds);
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:completionBlock];
                        break;
                    }
                    case KLCPopupDismissTypeBounceOut: {
                        [UIView animateWithDuration:bounce1Duration
                                              delay:0
                                            options:UIViewAnimationOptionCurveEaseOut
                                         animations:^(void){
                                             self->_containerView.transform = CGAffineTransformMakeScale(1.1, 1.1);
                                         }
                                         completion:^(BOOL finished){
                                             [UIView animateWithDuration:bounce2Duration
                                                                   delay:0
                                                                 options:UIViewAnimationOptionCurveEaseIn
                                                              animations:^(void){
                                                                  self->_containerView.alpha = 0.0;
                                                                  self->_containerView.transform = CGAffineTransformMakeScale(0.1, 0.1);
                                                              }
                                                              completion:completionBlock];
                                         }];
                        break;
                    }
                    case KLCPopupDismissTypeBounceOutToTop: {
                        [UIView animateWithDuration:bounce1Duration
                                              delay:0
                                            options:UIViewAnimationOptionCurveEaseOut
                                         animations:^(void){
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.y += 40.0;
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:^(BOOL finished){
                                             [UIView animateWithDuration:bounce2Duration
                                                                   delay:0
                                                                 options:UIViewAnimationOptionCurveEaseIn
                                                              animations:^(void){
                                                                  CGRect finalFrame = self->_containerView.frame;
                                                                  finalFrame.origin.y = -CGRectGetHeight(finalFrame);
                                                                  self->_containerView.frame = finalFrame;
                                                              }
                                                              completion:completionBlock];
                                         }];
                        break;
                    }
                    case KLCPopupDismissTypeBounceOutToBottom: {
                        [UIView animateWithDuration:bounce1Duration
                                              delay:0
                                            options:UIViewAnimationOptionCurveEaseOut
                                         animations:^(void){
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.y -= 40.0;
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:^(BOOL finished){
                                             [UIView animateWithDuration:bounce2Duration
                                                                   delay:0
                                                                 options:UIViewAnimationOptionCurveEaseIn
                                                              animations:^(void){
                                                                  CGRect finalFrame = self->_containerView.frame;
                                                                  finalFrame.origin.y = CGRectGetHeight(self.bounds);
                                                                  self->_containerView.frame = finalFrame;
                                                              }
                                                              completion:completionBlock];
                                         }];
                        break;
                    }
                    case KLCPopupDismissTypeBounceOutToLeft: {
                        [UIView animateWithDuration:bounce1Duration
                                              delay:0
                                            options:UIViewAnimationOptionCurveEaseOut
                                         animations:^(void){
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.x += 40.0;
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:^(BOOL finished){
                                             [UIView animateWithDuration:bounce2Duration
                                                                   delay:0
                                                                 options:UIViewAnimationOptionCurveEaseIn
                                                              animations:^(void){
                                                                  CGRect finalFrame = self->_containerView.frame;
                                                                  finalFrame.origin.x = -CGRectGetWidth(finalFrame);
                                                                  self->_containerView.frame = finalFrame;
                                                              }
                                                              completion:completionBlock];
                                         }];
                        break;
                    }
                    case KLCPopupDismissTypeBounceOutToRight: {
                        [UIView animateWithDuration:bounce1Duration
                                              delay:0
                                            options:UIViewAnimationOptionCurveEaseOut
                                         animations:^(void){
                                             CGRect finalFrame = self->_containerView.frame;
                                             finalFrame.origin.x -= 40.0;
                                             self->_containerView.frame = finalFrame;
                                         }
                                         completion:^(BOOL finished){
                                             [UIView animateWithDuration:bounce2Duration
                                                                   delay:0
                                                                 options:UIViewAnimationOptionCurveEaseIn
                                                              animations:^(void){
                                                                  CGRect finalFrame = self->_containerView.frame;
                                                                  finalFrame.origin.x = CGRectGetWidth(self.bounds);
                                                                  self->_containerView.frame = finalFrame;
                                                              }
                                                              completion:completionBlock];
                                         }];
                        break;
                    }
                    default: {
                        self.containerView.alpha = 0.0;
                        completionBlock(YES);
                        break;
                    }
                }
            } else {
                self.containerView.alpha = 0.0;
                completionBlock(YES);
            }
            
          case KLCPopupDismissTypeSlideOutToRight: {
            [UIView animateWithDuration:0.30
                                  delay:0
                                options:kAnimationOptionCurveIOS7
                             animations:^{
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.x = CGRectGetWidth(self.bounds);
                               _containerView.frame = finalFrame;
                             }
                             completion:completionBlock];
            break;
          }
          case KLCPopupDismissTypeBounceOut: {
            [UIView animateWithDuration:bounce1Duration
                                  delay:0
                                options:UIViewAnimationOptionCurveEaseOut
                             animations:^(void){
                               _containerView.transform = CGAffineTransformMakeScale(1.1, 1.1);
                             }
                             completion:^(BOOL finished){
                               [UIView animateWithDuration:bounce2Duration
                                                     delay:0
                                                   options:UIViewAnimationOptionCurveEaseIn
                                                animations:^(void){
                                                  _containerView.alpha = 0.0;
                                                  _containerView.transform = CGAffineTransformMakeScale(0.1, 0.1);
                                                }
                                                completion:completionBlock];
                             }];
            break;
          }
          case KLCPopupDismissTypeBounceOutToTop: {
            [UIView animateWithDuration:bounce1Duration
                                  delay:0
                                options:UIViewAnimationOptionCurveEaseOut
                             animations:^(void){
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.y += 40.0;
                               _containerView.frame = finalFrame;
                             }
                             completion:^(BOOL finished){
                               [UIView animateWithDuration:bounce2Duration
                                                     delay:0
                                                   options:UIViewAnimationOptionCurveEaseIn
                                                animations:^(void){
                                                  CGRect finalFrame = _containerView.frame;
                                                  finalFrame.origin.y = -CGRectGetHeight(finalFrame);
                                                  _containerView.frame = finalFrame;
                                                }
                                                completion:completionBlock];
                             }];
            break;
          }
          case KLCPopupDismissTypeBounceOutToBottom: {
            [UIView animateWithDuration:bounce1Duration
                                  delay:0
                                options:UIViewAnimationOptionCurveEaseOut
                             animations:^(void){
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.y -= 40.0;
                               _containerView.frame = finalFrame;
                             }
                             completion:^(BOOL finished){
                               [UIView animateWithDuration:bounce2Duration
                                                     delay:0
                                                   options:UIViewAnimationOptionCurveEaseIn
                                                animations:^(void){
                                                  CGRect finalFrame = _containerView.frame;
                                                  finalFrame.origin.y = CGRectGetHeight(self.bounds);
                                                  _containerView.frame = finalFrame;
                                                }
                                                completion:completionBlock];
                             }];
            break;
          }
          case KLCPopupDismissTypeBounceOutToLeft: {
            [UIView animateWithDuration:bounce1Duration
                                  delay:0
                                options:UIViewAnimationOptionCurveEaseOut
                             animations:^(void){
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.x += 40.0;
                               _containerView.frame = finalFrame;
                             }
                             completion:^(BOOL finished){
                               [UIView animateWithDuration:bounce2Duration
                                                     delay:0
                                                   options:UIViewAnimationOptionCurveEaseIn
                                                animations:^(void){
                                                  CGRect finalFrame = _containerView.frame;
                                                  finalFrame.origin.x = -CGRectGetWidth(finalFrame);
                                                  _containerView.frame = finalFrame;
                                                }
                                                completion:completionBlock];
                             }];
            break;
          }
          case KLCPopupDismissTypeBounceOutToRight: {
            [UIView animateWithDuration:bounce1Duration
                                  delay:0
                                options:UIViewAnimationOptionCurveEaseOut
                             animations:^(void){
                               CGRect finalFrame = _containerView.frame;
                               finalFrame.origin.x -= 40.0;
                               _containerView.frame = finalFrame;
                             }
                             completion:^(BOOL finished){
                               [UIView animateWithDuration:bounce2Duration
                                                     delay:0
                                                   options:UIViewAnimationOptionCurveEaseIn
                                                animations:^(void){
                                                  CGRect finalFrame = _containerView.frame;
                                                  finalFrame.origin.x = CGRectGetWidth(self.bounds);
                                                  _containerView.frame = finalFrame;
                                                }
                                                completion:completionBlock];
                             }];
            break;
          }
          default: {
            self.containerView.alpha = 0.0;
            completionBlock(YES);
            break;
          }
        }
      } else {
        self.containerView.alpha = 0.0;
        completionBlock(YES);
      }
    });
  }
        });
    }
}
#pragma mark - Private
- (void)showWithParameters:(NSDictionary*)parameters {
  // If popup can be shown
  if (!_isBeingShown && !_isShowing && !_isBeingDismissed) {
    _isBeingShown = YES;
    _isShowing = NO;
    _isBeingDismissed = NO;
    
    [self willStartShowing];
    dispatch_async( dispatch_get_main_queue(), ^{
      // Prepare by adding to the top window.
      if(!self.superview){
        NSEnumerator *frontToBackWindows = [[[UIApplication sharedApplication] windows] reverseObjectEnumerator];
        for (UIWindow *window in frontToBackWindows) {
          if (window.windowLevel == UIWindowLevelNormal) {
            [window addSubview:self];
            break;
          }
        }
      }
      // Before we calculate layout for containerView, make sure we are transformed for current orientation.
      [self updateForInterfaceOrientation];
      // Make sure we're not hidden
      self.hidden = NO;
      self.alpha = 1.0;
      // Setup background view
      _backgroundView.alpha = 0.0;
      if (_maskType == KLCPopupMaskTypeDimmed) {
        _backgroundView.backgroundColor = [UIColor colorWithRed:(0.0/255.0f) green:(0.0/255.0f) blue:(0.0/255.0f) alpha:self.dimmedMaskAlpha];
      } else {
        _backgroundView.backgroundColor = [UIColor clearColor];
      }
      // Animate background if needed
      void (^backgroundAnimationBlock)(void) = ^(void) {
        _backgroundView.alpha = 1.0;
      };
      if (_showType != KLCPopupShowTypeNone) {
        // Make fade happen faster than motion. Use linear for fades.
        [UIView animateWithDuration:0.15
                              delay:0
                            options:UIViewAnimationOptionCurveLinear
                         animations:backgroundAnimationBlock
                         completion:NULL];
      } else {
        backgroundAnimationBlock();
      }
      // Determine duration. Default to 0 if none provided.
      NSTimeInterval duration;
      NSNumber* durationNumber = [parameters valueForKey:@"duration"];
      if (durationNumber != nil) {
        duration = [durationNumber doubleValue];
      } else {
        duration = 0.0;
      }
      // Setup completion block
      void (^completionBlock)(BOOL) = ^(BOOL finished) {
        _isBeingShown = NO;
        _isShowing = YES;
    // If popup can be shown
    if (!_isBeingShown && !_isShowing && !_isBeingDismissed) {
        _isBeingShown = YES;
        _isShowing = NO;
        _isBeingDismissed = NO;
        
        [self didFinishShowing];
        [self willStartShowing];
        
        if (self.didFinishShowingCompletion != nil) {
          self.didFinishShowingCompletion();
        }
        // Set to hide after duration if greater than zero.
        if (duration > 0.0) {
          [self performSelector:@selector(dismiss) withObject:nil afterDelay:duration];
        }
      };
      // Add contentView to container
      if (self.contentView.superview != _containerView) {
        [_containerView addSubview:self.contentView];
      }
      // Re-layout (this is needed if the contentView is using autoLayout)
      [self.contentView layoutIfNeeded];
      // Size container to match contentView
      CGRect containerFrame = _containerView.frame;
      containerFrame.size = self.contentView.frame.size;
      _containerView.frame = containerFrame;
      // Position contentView to fill it
      CGRect contentViewFrame = self.contentView.frame;
      contentViewFrame.origin = CGPointZero;
      self.contentView.frame = contentViewFrame;
      // Reset _containerView's constraints in case contentView is uaing autolayout.
      UIView* contentView = _contentView;
      NSDictionary* views = NSDictionaryOfVariableBindings(contentView);
      [_containerView removeConstraints:_containerView.constraints];
      [_containerView addConstraints:
       [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[contentView]|"
                                               options:0
                                               metrics:nil
                                                 views:views]];
      [_containerView addConstraints:
       [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[contentView]|"
                                               options:0
                                               metrics:nil
                                                 views:views]];
      // Determine final position and necessary autoresizingMask for container.
      CGRect finalContainerFrame = containerFrame;
      UIViewAutoresizing containerAutoresizingMask = UIViewAutoresizingNone;
      // Use explicit center coordinates if provided.
      NSValue* centerValue = [parameters valueForKey:@"center"];
      if (centerValue != nil) {
        CGPoint centerInView = [centerValue CGPointValue];
        CGPoint centerInSelf;
        // Convert coordinates from provided view to self. Otherwise use as-is.
        UIView* fromView = [parameters valueForKey:@"view"];
        if (fromView != nil) {
          centerInSelf = [self convertPoint:centerInView fromView:fromView];
        } else {
          centerInSelf = centerInView;
        }
        finalContainerFrame.origin.x = (centerInSelf.x - CGRectGetWidth(finalContainerFrame)/2.0);
        finalContainerFrame.origin.y = (centerInSelf.y - CGRectGetHeight(finalContainerFrame)/2.0);
        containerAutoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
      }
      // Otherwise use relative layout. Default to center if none provided.
      else {
        NSValue* layoutValue = [parameters valueForKey:@"layout"];
        KLCPopupLayout layout;
        if (layoutValue != nil) {
          layout = [layoutValue KLCPopupLayoutValue];
        } else {
          layout = KLCPopupLayoutCenter;
        }
        switch (layout.horizontal) {
        dispatch_async( dispatch_get_main_queue(), ^{
            
          case KLCPopupHorizontalLayoutLeft: {
            finalContainerFrame.origin.x = 0.0;
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleRightMargin;
            break;
          }
            // Prepare by adding to the top window.
            if(!self.superview){
                NSEnumerator *frontToBackWindows = [[[UIApplication sharedApplication] windows] reverseObjectEnumerator];
                for (UIWindow *window in frontToBackWindows) {
                    if (window.windowLevel == UIWindowLevelNormal) {
                        [window addSubview:self];
                        break;
                    }
                }
            }
            
          case KLCPopupHorizontalLayoutLeftOfCenter: {
            finalContainerFrame.origin.x = floorf(CGRectGetWidth(self.bounds)/3.0 - CGRectGetWidth(containerFrame)/2.0);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
            break;
          }
            // Before we calculate layout for containerView, make sure we are transformed for current orientation.
            [self updateForInterfaceOrientation];
            
          case KLCPopupHorizontalLayoutCenter: {
            finalContainerFrame.origin.x = floorf((CGRectGetWidth(self.bounds) - CGRectGetWidth(containerFrame))/2.0);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
            break;
          }
            // Make sure we're not hidden
            self.hidden = NO;
            self.alpha = 1.0;
            
          case KLCPopupHorizontalLayoutRightOfCenter: {
            finalContainerFrame.origin.x = floorf(CGRectGetWidth(self.bounds)*2.0/3.0 - CGRectGetWidth(containerFrame)/2.0);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
            break;
          }
            // Setup background view
            self.backgroundView.alpha = 0.0;
            
          case KLCPopupHorizontalLayoutRight: {
            finalContainerFrame.origin.x = CGRectGetWidth(self.bounds) - CGRectGetWidth(containerFrame);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin;
            break;
          }
            if (self.maskType == KLCPopupMaskTypeDimmed) {
                self.backgroundView.backgroundColor = [UIColor colorWithRed:(0.0/255.0f) green:(0.0/255.0f) blue:(0.0/255.0f) alpha:self.dimmedMaskAlpha];
            } else {
                self.backgroundView.backgroundColor = [UIColor clearColor];
            }
            
          default:
            break;
        }
        // Vertical
        switch (layout.vertical) {
            // Animate background if needed
            void (^backgroundAnimationBlock)(void) = ^(void) {
                self.backgroundView.alpha = 1.0;
            };
            
          case KLCPopupVerticalLayoutTop: {
            finalContainerFrame.origin.y = 0;
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleBottomMargin;
            break;
          }
            if (self.showType != KLCPopupShowTypeNone) {
                // Make fade happen faster than motion. Use linear for fades.
                [UIView animateWithDuration:0.15
                                      delay:0
                                    options:UIViewAnimationOptionCurveLinear
                                 animations:backgroundAnimationBlock
                                 completion:NULL];
            } else {
                backgroundAnimationBlock();
            }
            
          case KLCPopupVerticalLayoutAboveCenter: {
            finalContainerFrame.origin.y = floorf(CGRectGetHeight(self.bounds)/3.0 - CGRectGetHeight(containerFrame)/2.0);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
            break;
          }
            // Determine duration. Default to 0 if none provided.
            NSTimeInterval duration;
            NSNumber* durationNumber = [parameters valueForKey:@"duration"];
            if (durationNumber != nil) {
                duration = [durationNumber doubleValue];
            } else {
                duration = 0.0;
            }
            
          case KLCPopupVerticalLayoutCenter: {
            finalContainerFrame.origin.y = floorf((CGRectGetHeight(self.bounds) - CGRectGetHeight(containerFrame))/2.0);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
            break;
          }
            // Setup completion block
            void (^completionBlock)(BOOL) = ^(BOOL finished) {
                self->_isBeingShown = NO;
                self->_isShowing = YES;
                self->_isBeingDismissed = NO;
                [self didFinishShowing];
                if (self.didFinishShowingCompletion != nil) {
                    self.didFinishShowingCompletion();
                }
                // Set to hide after duration if greater than zero.
                if (duration > 0.0) {
                    [self performSelector:@selector(dismiss) withObject:nil afterDelay:duration];
                }
            };
            
          case KLCPopupVerticalLayoutBelowCenter: {
            finalContainerFrame.origin.y = floorf(CGRectGetHeight(self.bounds)*2.0/3.0 - CGRectGetHeight(containerFrame)/2.0);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
            break;
          }
            // Add contentView to container
            if (self.contentView.superview != self->_containerView) {
                [self->_containerView addSubview:self.contentView];
            }
            
          case KLCPopupVerticalLayoutBottom: {
            finalContainerFrame.origin.y = CGRectGetHeight(self.bounds) - CGRectGetHeight(containerFrame);
            containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin;
            break;
          }
            // Re-layout (this is needed if the contentView is using autoLayout)
            [self.contentView layoutIfNeeded];
            
          default:
            break;
        }
      }
      _containerView.autoresizingMask = containerAutoresizingMask;
      // Animate content if needed
      switch (_showType) {
        case KLCPopupShowTypeFadeIn: {
          _containerView.alpha = 0.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.15
                                delay:0
                              options:UIViewAnimationOptionCurveLinear
                           animations:^{
                             _containerView.alpha = 1.0;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeGrowIn: {
          _containerView.alpha = 0.0;
          // set frame before transform here...
          CGRect startFrame = finalContainerFrame;
          _containerView.frame = startFrame;
          _containerView.transform = CGAffineTransformMakeScale(0.85, 0.85);
          [UIView animateWithDuration:0.15
                                delay:0
                              options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                           animations:^{
                             _containerView.alpha = 1.0;
                             // set transform before frame here...
                             _containerView.transform = CGAffineTransformIdentity;
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeShrinkIn: {
          _containerView.alpha = 0.0;
          // set frame before transform here...
          CGRect startFrame = finalContainerFrame;
          _containerView.frame = startFrame;
          _containerView.transform = CGAffineTransformMakeScale(1.25, 1.25);
          [UIView animateWithDuration:0.15
                                delay:0
                              options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                           animations:^{
                             _containerView.alpha = 1.0;
                             // set transform before frame here...
                             _containerView.transform = CGAffineTransformIdentity;
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeSlideInFromTop: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.y = -CGRectGetHeight(finalContainerFrame);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.30
                                delay:0
                              options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeSlideInFromBottom: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.y = CGRectGetHeight(self.bounds);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.30
                                delay:0
                              options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeSlideInFromLeft: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.x = -CGRectGetWidth(finalContainerFrame);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.30
                                delay:0
                              options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeSlideInFromRight: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.x = CGRectGetWidth(self.bounds);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.30
                                delay:0
                              options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeBounceIn: {
          _containerView.alpha = 0.0;
          // set frame before transform here...
          CGRect startFrame = finalContainerFrame;
          _containerView.frame = startFrame;
          _containerView.transform = CGAffineTransformMakeScale(0.1, 0.1);
          [UIView animateWithDuration:0.6
                                delay:0.0
               usingSpringWithDamping:0.8
                initialSpringVelocity:15.0
                              options:0
                           animations:^{
                             _containerView.alpha = 1.0;
                             _containerView.transform = CGAffineTransformIdentity;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeBounceInFromTop: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.y = -CGRectGetHeight(finalContainerFrame);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.6
                                delay:0.0
               usingSpringWithDamping:0.8
                initialSpringVelocity:10.0
                              options:0
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeBounceInFromBottom: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.y = CGRectGetHeight(self.bounds);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.6
                                delay:0.0
               usingSpringWithDamping:0.8
                initialSpringVelocity:10.0
                              options:0
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeBounceInFromLeft: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.x = -CGRectGetWidth(finalContainerFrame);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.6
                                delay:0.0
               usingSpringWithDamping:0.8
                initialSpringVelocity:10.0
                              options:0
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        case KLCPopupShowTypeBounceInFromRight: {
          _containerView.alpha = 1.0;
          _containerView.transform = CGAffineTransformIdentity;
          CGRect startFrame = finalContainerFrame;
          startFrame.origin.x = CGRectGetWidth(self.bounds);
          _containerView.frame = startFrame;
          [UIView animateWithDuration:0.6
                                delay:0.0
               usingSpringWithDamping:0.8
                initialSpringVelocity:10.0
                              options:0
                           animations:^{
                             _containerView.frame = finalContainerFrame;
                           }
                           completion:completionBlock];
          break;
        }
        default: {
          self.containerView.alpha = 1.0;
          self.containerView.transform = CGAffineTransformIdentity;
          self.containerView.frame = finalContainerFrame;
          completionBlock(YES);
          break;
        }
      }
    });
  }
            // Size container to match contentView
            CGRect containerFrame = self->_containerView.frame;
            containerFrame.size = self.contentView.frame.size;
            self->_containerView.frame = containerFrame;
            // Position contentView to fill it
            CGRect contentViewFrame = self.contentView.frame;
            contentViewFrame.origin = CGPointZero;
            self.contentView.frame = contentViewFrame;
            // Reset _containerView's constraints in case contentView is uaing autolayout.
            UIView *contentView = self->_contentView;
            NSDictionary* views = NSDictionaryOfVariableBindings(contentView);
            [self->_containerView removeConstraints:self->_containerView.constraints];
            [self->_containerView addConstraints:
             [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[contentView]|"
                                                     options:0
                                                     metrics:nil
                                                       views:views]];
            [self->_containerView addConstraints:
             [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[contentView]|"
                                                     options:0
                                                     metrics:nil
                                                       views:views]];
            // Determine final position and necessary autoresizingMask for container.
            CGRect finalContainerFrame = containerFrame;
            UIViewAutoresizing containerAutoresizingMask = UIViewAutoresizingNone;
            // Use explicit center coordinates if provided.
            NSValue* centerValue = [parameters valueForKey:@"center"];
            if (centerValue != nil) {
                CGPoint centerInView = [centerValue CGPointValue];
                CGPoint centerInSelf;
                // Convert coordinates from provided view to self. Otherwise use as-is.
                UIView* fromView = [parameters valueForKey:@"view"];
                if (fromView != nil) {
                    centerInSelf = [self convertPoint:centerInView fromView:fromView];
                } else {
                    centerInSelf = centerInView;
                }
                finalContainerFrame.origin.x = (centerInSelf.x - CGRectGetWidth(finalContainerFrame)/2.0);
                finalContainerFrame.origin.y = (centerInSelf.y - CGRectGetHeight(finalContainerFrame)/2.0);
                containerAutoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
            }
            // Otherwise use relative layout. Default to center if none provided.
            else {
                NSValue* layoutValue = [parameters valueForKey:@"layout"];
                KLCPopupLayout layout;
                if (layoutValue != nil) {
                    layout = [layoutValue KLCPopupLayoutValue];
                } else {
                    layout = KLCPopupLayoutCenter;
                }
                switch (layout.horizontal) {
                    case KLCPopupHorizontalLayoutLeft: {
                        finalContainerFrame.origin.x = 0.0;
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleRightMargin;
                        break;
                    }
                    case KLCPopupHorizontalLayoutLeftOfCenter: {
                        finalContainerFrame.origin.x = floorf(CGRectGetWidth(self.bounds)/3.0 - CGRectGetWidth(containerFrame)/2.0);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
                        break;
                    }
                    case KLCPopupHorizontalLayoutCenter: {
                        finalContainerFrame.origin.x = floorf((CGRectGetWidth(self.bounds) - CGRectGetWidth(containerFrame))/2.0);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
                        break;
                    }
                    case KLCPopupHorizontalLayoutRightOfCenter: {
                        finalContainerFrame.origin.x = floorf(CGRectGetWidth(self.bounds)*2.0/3.0 - CGRectGetWidth(containerFrame)/2.0);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
                        break;
                    }
                    case KLCPopupHorizontalLayoutRight: {
                        finalContainerFrame.origin.x = CGRectGetWidth(self.bounds) - CGRectGetWidth(containerFrame);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleLeftMargin;
                        break;
                    }
                    default:
                        break;
                }
                // Vertical
                switch (layout.vertical) {
                    case KLCPopupVerticalLayoutTop: {
                        finalContainerFrame.origin.y = 0;
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleBottomMargin;
                        break;
                    }
                    case KLCPopupVerticalLayoutAboveCenter: {
                        finalContainerFrame.origin.y = floorf(CGRectGetHeight(self.bounds)/3.0 - CGRectGetHeight(containerFrame)/2.0);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
                        break;
                    }
                    case KLCPopupVerticalLayoutCenter: {
                        finalContainerFrame.origin.y = floorf((CGRectGetHeight(self.bounds) - CGRectGetHeight(containerFrame))/2.0);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
                        break;
                    }
                    case KLCPopupVerticalLayoutBelowCenter: {
                        finalContainerFrame.origin.y = floorf(CGRectGetHeight(self.bounds)*2.0/3.0 - CGRectGetHeight(containerFrame)/2.0);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
                        break;
                    }
                    case KLCPopupVerticalLayoutBottom: {
                        finalContainerFrame.origin.y = CGRectGetHeight(self.bounds) - CGRectGetHeight(containerFrame);
                        containerAutoresizingMask = containerAutoresizingMask | UIViewAutoresizingFlexibleTopMargin;
                        break;
                    }
                    default:
                        break;
                }
            }
            self->_containerView.autoresizingMask = containerAutoresizingMask;
            // Animate content if needed
            switch (self.showType) {
                case KLCPopupShowTypeFadeIn: {
                    self->_containerView.alpha = 0.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.15
                                          delay:0
                                        options:UIViewAnimationOptionCurveLinear
                                     animations:^{
                                         self->_containerView.alpha = 1.0;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeGrowIn: {
                    self->_containerView.alpha = 0.0;
                    // set frame before transform here...
                    CGRect startFrame = finalContainerFrame;
                    self->_containerView.frame = startFrame;
                    self->_containerView.transform = CGAffineTransformMakeScale(0.85, 0.85);
                    [UIView animateWithDuration:0.15
                                          delay:0
                                        options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                                     animations:^{
                                         self->_containerView.alpha = 1.0;
                                         // set transform before frame here...
                                         self->_containerView.transform = CGAffineTransformIdentity;
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeShrinkIn: {
                    self->_containerView.alpha = 0.0;
                    // set frame before transform here...
                    CGRect startFrame = finalContainerFrame;
                    self->_containerView.frame = startFrame;
                    self->_containerView.transform = CGAffineTransformMakeScale(1.25, 1.25);
                    [UIView animateWithDuration:0.15
                                          delay:0
                                        options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                                     animations:^{
                                         self->_containerView.alpha = 1.0;
                                         // set transform before frame here...
                                         self->_containerView.transform = CGAffineTransformIdentity;
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeSlideInFromTop: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.y = -CGRectGetHeight(finalContainerFrame);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.30
                                          delay:0
                                        options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeSlideInFromBottom: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.y = CGRectGetHeight(self.bounds);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.30
                                          delay:0
                                        options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeSlideInFromLeft: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.x = -CGRectGetWidth(finalContainerFrame);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.30
                                          delay:0
                                        options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeSlideInFromRight: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.x = CGRectGetWidth(self.bounds);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.30
                                          delay:0
                                        options:kAnimationOptionCurveIOS7 // note: this curve ignores durations
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeBounceIn: {
                    self->_containerView.alpha = 0.0;
                    // set frame before transform here...
                    CGRect startFrame = finalContainerFrame;
                    self->_containerView.frame = startFrame;
                    self->_containerView.transform = CGAffineTransformMakeScale(0.1, 0.1);
                    [UIView animateWithDuration:0.6
                                          delay:0.0
                         usingSpringWithDamping:0.8
                          initialSpringVelocity:15.0
                                        options:0
                                     animations:^{
                                         self->_containerView.alpha = 1.0;
                                         self->_containerView.transform = CGAffineTransformIdentity;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeBounceInFromTop: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.y = -CGRectGetHeight(finalContainerFrame);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.6
                                          delay:0.0
                         usingSpringWithDamping:0.8
                          initialSpringVelocity:10.0
                                        options:0
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeBounceInFromBottom: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.y = CGRectGetHeight(self.bounds);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.6
                                          delay:0.0
                         usingSpringWithDamping:0.8
                          initialSpringVelocity:10.0
                                        options:0
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeBounceInFromLeft: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.x = -CGRectGetWidth(finalContainerFrame);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.6
                                          delay:0.0
                         usingSpringWithDamping:0.8
                          initialSpringVelocity:10.0
                                        options:0
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                case KLCPopupShowTypeBounceInFromRight: {
                    self->_containerView.alpha = 1.0;
                    self->_containerView.transform = CGAffineTransformIdentity;
                    CGRect startFrame = finalContainerFrame;
                    startFrame.origin.x = CGRectGetWidth(self.bounds);
                    self->_containerView.frame = startFrame;
                    [UIView animateWithDuration:0.6
                                          delay:0.0
                         usingSpringWithDamping:0.8
                          initialSpringVelocity:10.0
                                        options:0
                                     animations:^{
                                         self->_containerView.frame = finalContainerFrame;
                                     }
                                     completion:completionBlock];
                    break;
                }
                default: {
                    self.containerView.alpha = 1.0;
                    self.containerView.transform = CGAffineTransformIdentity;
                    self.containerView.frame = finalContainerFrame;
                    completionBlock(YES);
                    break;
                }
            }
        });
    }
}
- (void)dismiss {
  [self dismiss:YES];
    [self dismiss:YES];
}
- (void)updateForInterfaceOrientation {
  // We must manually fix orientation prior to iOS 8
  if (([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending)) {
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    CGFloat angle;
    
    switch (orientation) {
      case UIInterfaceOrientationPortraitUpsideDown:
        angle = M_PI;
        break;
      case UIInterfaceOrientationLandscapeLeft:
        angle = -M_PI/2.0f;;
    // We must manually fix orientation prior to iOS 8
    if (([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending)) {
        
        break;
      case UIInterfaceOrientationLandscapeRight:
        angle = M_PI/2.0f;
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
        CGFloat angle;
        
        break;
      default: // as UIInterfaceOrientationPortrait
        angle = 0.0;
        break;
        switch (orientation) {
            case UIInterfaceOrientationPortraitUpsideDown:
                angle = M_PI;
                break;
            case UIInterfaceOrientationLandscapeLeft:
                angle = -M_PI/2.0f;;
                break;
            case UIInterfaceOrientationLandscapeRight:
                angle = M_PI/2.0f;
                break;
            default: // as UIInterfaceOrientationPortrait
                angle = 0.0;
                break;
        }
        self.transform = CGAffineTransformMakeRotation(angle);
    }
    
    self.transform = CGAffineTransformMakeRotation(angle);
  }
  self.frame = self.window.bounds;
    self.frame = self.window.bounds;
}
#pragma mark - Notification handlers
- (void)didChangeStatusBarOrientation:(NSNotification*)notification {
  [self updateForInterfaceOrientation];
    [self updateForInterfaceOrientation];
}
#pragma mark - Subclassing
- (void)willStartShowing {
}
- (void)didFinishShowing {
}
- (void)willStartDismissing {
}
- (void)didFinishDismissing {
}
@end
@@ -1064,29 +1067,29 @@
- (void)forEachPopupDoBlock:(void (^)(KLCPopup* popup))block {
  for (UIView *subview in self.subviews)
  {
    if ([subview isKindOfClass:[KLCPopup class]])
    for (UIView *subview in self.subviews)
    {
      block((KLCPopup *)subview);
    } else {
      [subview forEachPopupDoBlock:block];
        if ([subview isKindOfClass:[KLCPopup class]])
        {
            block((KLCPopup *)subview);
        } else {
            [subview forEachPopupDoBlock:block];
        }
    }
  }
}
- (void)dismissPresentingPopup {
  // Iterate over superviews until you find a KLCPopup and dismiss it, then gtfo
  UIView* view = self;
  while (view != nil) {
    if ([view isKindOfClass:[KLCPopup class]]) {
      [(KLCPopup*)view dismiss:YES];
      break;
    // Iterate over superviews until you find a KLCPopup and dismiss it, then gtfo
    UIView* view = self;
    while (view != nil) {
        if ([view isKindOfClass:[KLCPopup class]]) {
            [(KLCPopup*)view dismiss:YES];
            break;
        }
        view = [view superview];
    }
    view = [view superview];
  }
}
@end
@@ -1098,16 +1101,16 @@
+ (NSValue *)valueWithKLCPopupLayout:(KLCPopupLayout)layout
{
  return [NSValue valueWithBytes:&layout objCType:@encode(KLCPopupLayout)];
    return [NSValue valueWithBytes:&layout objCType:@encode(KLCPopupLayout)];
}
- (KLCPopupLayout)KLCPopupLayoutValue
{
  KLCPopupLayout layout;
  [self getValue:&layout];
  return layout;
    KLCPopupLayout layout;
    [self getValue:&layout];
    return layout;
}
@end
MIduo/Êý¾Ý/lib/LBXScan/LBXScan/LBXScanLineAnimation.m
@@ -28,13 +28,13 @@
- (void)stepAnimation
{
- (void)stepAnimation {
    if (!isAnimationing) {
        return;
    }
    
    CGFloat leftx = _animationRect.origin.x + 5;
    CGFloat width = _animationRect.size.width - 10;
    
@@ -47,40 +47,35 @@
    __weak __typeof(self) weakSelf = self;
    
    [UIView animateWithDuration:0.5 animations:^{
         weakSelf.alpha = 1.0;
        weakSelf.alpha = 1.0;
        
    } completion:^(BOOL finished) {
        
    } completion:^(BOOL finished)
     {
     }];
    }];
    
    [UIView animateWithDuration:3 animations:^{
        CGFloat leftx = _animationRect.origin.x + 5;
        CGFloat width = _animationRect.size.width - 10;
        
        CGFloat leftx = self.animationRect.origin.x + 5;
        CGFloat width = self.animationRect.size.width - 10;
        
        weakSelf.frame = CGRectMake(leftx, self.animationRect.origin.y + self.animationRect.size.height - 8, width, 4);
        
        weakSelf.frame = CGRectMake(leftx, _animationRect.origin.y + _animationRect.size.height - 8, width, 4);
    } completion:^(BOOL finished) {
        
    } completion:^(BOOL finished)
     {
         self.hidden = YES;
         [weakSelf performSelector:@selector(stepAnimation) withObject:nil afterDelay:0.3];
     }];
        self.hidden = YES;
        [weakSelf performSelector:@selector(stepAnimation) withObject:nil afterDelay:0.3];
    }];
}
- (void)startAnimatingWithRect:(CGRect)animationRect InView:(UIView *)parentView Image:(UIImage*)image
{
- (void)startAnimatingWithRect:(CGRect)animationRect InView:(UIView *)parentView Image:(UIImage*)image {
    if (isAnimationing) {
        return;
    }
    
    isAnimationing = YES;
    
    self.animationRect = animationRect;
    down = YES;
@@ -96,68 +91,68 @@
    [parentView addSubview:self];
    
    [self startAnimating_UIViewAnimation];
//    [self startAnimating_NSTimer];
    // [self startAnimating_NSTimer];
}
- (void)startAnimating_UIViewAnimation
{
     [self stepAnimation];
- (void)startAnimating_UIViewAnimation {
    [self stepAnimation];
}
- (void)startAnimating_NSTimer
{
- (void)startAnimating_NSTimer {
    timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(scanLineAnimation) userInfo:nil repeats:YES];
}
-(void)scanLineAnimation
{
-(void)scanLineAnimation {
    CGFloat centery = CGRectGetMinY(_animationRect) + CGRectGetHeight(_animationRect)/2;
    CGFloat leftx = _animationRect.origin.x + 5;
    CGFloat width = _animationRect.size.width - 10;
    
    if (down)
    {
    if (down) {
        num++;
        
        self.frame = CGRectMake(leftx, centery+2*num, width, 2);
        
        if (centery+2*num > (CGRectGetMinY(_animationRect) + CGRectGetHeight(_animationRect) - 5 ) )
        {
        if (centery+2*num > (CGRectGetMinY(_animationRect) + CGRectGetHeight(_animationRect) - 5 ) ) {
            down = NO;
        }
    }
    else {
    } else {
        num --;
        self.frame = CGRectMake(leftx, centery+2*num, width, 2);
        if (centery+2*num < (CGRectGetMinY(_animationRect) + 5 ) )
        {
        if (centery+2*num < (CGRectGetMinY(_animationRect) + 5 ) ) {
            down = YES;
        }
    }
}
- (void)dealloc
{
- (void)dealloc {
    [self stopAnimating];
}
- (void)stopAnimating
{
- (void)stopAnimating {
    if (isAnimationing) {
        
        isAnimationing = NO;
        
        if (timer) {
            [timer invalidate];
            timer = nil;
        }
        
        [self removeFromSuperview];
    }
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
}
@end
MIduo/Êý¾Ý/lib/LBXScan/LBXScan/LBXScanNative.h
@@ -65,9 +65,9 @@
/*!
 *  ä¿®æ”¹æ‰«ç ç±»åž‹ï¼šäºŒç»´ç ã€æ¡å½¢ç 
 *
 *  @param objType
 *  @param objType
 */
- (void)changeScanType:(NSArray*)objType;
- (void)changeScanType:(NSArray *)objType;
/**
MIduo/Êý¾Ý/lib/LBXScan/LBXScan/LBXScanNative.m
@@ -20,7 +20,7 @@
@property(nonatomic,assign)BOOL isNeedCaputureImage;
//扫码结果
@property (nonatomic, strong) NSMutableArray<LBXScanResult*> *arrayResult;
@property (nonatomic, strong) NSMutableArray<LBXScanResult *> *arrayResult;
//扫码类型
@property (nonatomic, strong) NSArray* arrayBarCodeType;
@@ -285,8 +285,8 @@
}
-(UIImage *)getImageFromLayer:(CALayer *)layer size:(CGSize)size
{
-(UIImage *)getImageFromLayer:(CALayer *)layer size:(CGSize)size {
    UIGraphicsBeginImageContextWithOptions(size, YES, [[UIScreen mainScreen]scale]);
    [layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
@@ -295,11 +295,14 @@
    return image;
}
- (AVCaptureConnection *)connectionWithMediaType:(NSString *)mediaType fromConnections:(NSArray *)connections
{
- (AVCaptureConnection *)connectionWithMediaType:(NSString *)mediaType fromConnections:(NSArray *)connections {
    for ( AVCaptureConnection *connection in connections ) {
        for ( AVCaptureInputPort *port in [connection inputPorts] ) {
            if ( [[port mediaType] isEqual:mediaType] ) {
                return connection;
            }
        }
@@ -307,65 +310,55 @@
    return nil;
}
- (void)captureImage
{
    AVCaptureConnection *stillImageConnection = [self connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
- (void)captureImage {
    AVCaptureConnection *stillImageConnection = [self connectionWithMediaType:AVMediaTypeVideo
                                                              fromConnections:[[self stillImageOutput] connections]];
    
    
    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:stillImageConnection
                                                         completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error)
     {
                                                         completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
         [self stopScan];
         
         if (imageDataSampleBuffer)
         {
         if (imageDataSampleBuffer) {
             NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
             
             UIImage *img = [UIImage imageWithData:imageData];
             
             for (LBXScanResult* result in _arrayResult) {
             for (LBXScanResult* result in self.arrayResult) {
                 
                 result.imgScanned = img;
             }
         }
         
         if (_blockScanResult)
         {
             _blockScanResult(_arrayResult);
         if (self.blockScanResult) {
             self.blockScanResult(self.arrayResult);
         }
     }];
}
#pragma mark AVCaptureMetadataOutputObjectsDelegate
- (void)captureOutput2:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
{
- (void)captureOutput2:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection {
   
    //识别扫码类型
    for(AVMetadataObject *current in metadataObjects)
    {
        if ([current isKindOfClass:[AVMetadataMachineReadableCodeObject class]] )
        {
    for(AVMetadataObject *current in metadataObjects) {
        if ([current isKindOfClass:[AVMetadataMachineReadableCodeObject class]] ) {
            
            NSString *scannedResult = [(AVMetadataMachineReadableCodeObject *) current stringValue];
            NSLog(@"type:%@",current.type);
            NSLog(@"result:%@",scannedResult);
            
            //测试可以同时识别多个二维码
        }
    }
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
{
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects
       fromConnection:(AVCaptureConnection *)connection {
    if (!bNeedScanResult) {
        return;
    }
@@ -375,25 +368,27 @@
    if (!_arrayResult) {
        
        self.arrayResult = [NSMutableArray arrayWithCapacity:1];
    }
    else
    {
    } else {
        [_arrayResult removeAllObjects];
    }
    
    //识别扫码类型
    for(AVMetadataObject *current in metadataObjects)
    {
        if ([current isKindOfClass:[AVMetadataMachineReadableCodeObject class]] )
        {
    for(AVMetadataObject *current in metadataObjects) {
        if ([current isKindOfClass:[AVMetadataMachineReadableCodeObject class]]) {
            bNeedScanResult = NO;
            
            NSLog(@"type:%@",current.type);
            NSString *scannedResult = [(AVMetadataMachineReadableCodeObject *) current stringValue];
            
            if (scannedResult && ![scannedResult isEqualToString:@""])
            {
            if (scannedResult && ![scannedResult isEqualToString:@""]) {
                LBXScanResult *result = [LBXScanResult new];
                result.strScanned = scannedResult;
                result.strBarCodeType = current.type;
                
@@ -403,33 +398,34 @@
        }
    }
    
    if (_arrayResult.count < 1)
    {
    if (_arrayResult.count < 1) {
        bNeedScanResult = YES;
        return;
    }
    
    if (_isNeedCaputureImage)
    {
    if (_isNeedCaputureImage) {
        [self captureImage];
    }
    else
    {
    } else {
        [self stopScan];
        
        if (_blockScanResult) {
            _blockScanResult(_arrayResult);
        }
    }
}
/**
 @brief  é»˜è®¤æ”¯æŒç çš„类别
 @return æ”¯æŒç±»åˆ« æ•°ç»„
 */
- (NSArray *)defaultMetaDataObjectTypes
{
- (NSArray *)defaultMetaDataObjectTypes {
    NSMutableArray *types = [@[AVMetadataObjectTypeQRCode,
                               AVMetadataObjectTypeUPCECode,
                               AVMetadataObjectTypeCode39Code,
@@ -441,18 +437,15 @@
                               AVMetadataObjectTypePDF417Code,
                               AVMetadataObjectTypeAztecCode] mutableCopy];
    
    if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1)
    {
    if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) {
        [types addObjectsFromArray:@[
                                     AVMetadataObjectTypeInterleaved2of5Code,
                                     AVMetadataObjectTypeITF14Code,
                                     AVMetadataObjectTypeDataMatrixCode
                                     ]];
    }
    return types;
}
@end
MIduo/Êý¾Ý/lib/LBXScan/LBXScan/LBXScanNetAnimation.m
@@ -14,8 +14,8 @@
    BOOL isAnimationing;
}
@property (nonatomic,assign) CGRect animationRect;
@property (nonatomic,strong) UIImageView *scanImageView;
@property (nonatomic, assign) CGRect animationRect;
@property (nonatomic, strong) UIImageView *scanImageView;
@end
@@ -54,7 +54,7 @@
    [UIView animateWithDuration:1.4 animations:^{
        weakSelf.alpha = 1.0;
        
        _scanImageView.frame = CGRectMake(0, scanNetImageViewW-scanNetImageH, scanNetImageViewW, scanNetImageH);
        self.scanImageView.frame = CGRectMake(0, scanNetImageViewW-scanNetImageH, scanNetImageViewW, scanNetImageH);
        
    } completion:^(BOOL finished)
     {
MIduo/Êý¾Ý/lib/LBXScan/LBXScan/LBXScanWrapper.h
@@ -84,7 +84,7 @@
/*!
 *  ä¿®æ”¹æ‰«ç ç±»åž‹
 *
 *  @param objType æ‰«ç ç±»åž‹: AVMetadataObjectTypeQRCode:二维码   AVMetadataObjectTypeEAN13Code:条形码
 *  @param barCodeType æ‰«ç ç±»åž‹: AVMetadataObjectTypeQRCode:二维码   AVMetadataObjectTypeEAN13Code:条形码
 */
- (void)changeScanObjType:(NSArray*)barCodeType;
MIduo/Êý¾Ý/lib/LBXScan/ScanQRViewController.m
@@ -24,7 +24,7 @@
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"二维码/条码";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor,nil]];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
//    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
MIduo/Êý¾Ý/lib/LBXScan/ZXingObjC/ZXingObjC/client/ZXCGImageLuminanceSource.m
@@ -239,7 +239,7 @@
        rgbPixelOut = 255;
      }
      _data[i] = rgbPixelOut;
      self.data[i] = rgbPixelOut;
    }
  });
MIduo/Êý¾Ý/lib/LBXScan/ZXingObjC/ZXingObjC/common/ZXCharacterSetECI.h
@@ -31,7 +31,7 @@
+ (ZXCharacterSetECI *)characterSetECIByValue:(int)value;
/**
 * @param name character set ECI encoding name
 * @param encoding character set ECI encoding name
 * @return CharacterSetECI representing ECI for character encoding, or nil if it is legal
 *   but unsupported
 */
MIduo/½çÃæ/ÎÒµÄ/LoginViewController.m
@@ -45,15 +45,15 @@
    [super viewWillDisappear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [YTHsharedManger startManger].isfirst = YES;
    self.loginType = 0;
//    [YTHsharedManger startManger].isBound = NO;
    //    [YTHsharedManger startManger].isBound = NO;
    if (IsiPhoneX ) {
        self.closeConstraint.constant = 45;
    }else{
@@ -75,21 +75,21 @@
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(WeChatHasLoged:) name:@"PostWeChatLogin" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IFneedWXLogin:) name:@"IFNEEDWEIXINLOGIN" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(GetthroughAccount:) name:@"GetthroughAccount" object:nil];
    [self isFirstLogin];
    if(![WXApi isWXAppInstalled]){//判断用户是否安装客户端
//        self.wxButton.hidden = YES;
        //        self.wxButton.hidden = YES;
        self.WXLoginView.hidden = YES;
    }else{
//        self.wxButton.hidden = NO;
        //        self.wxButton.hidden = NO;
        self.WXLoginView.hidden = NO;
    }
//    BOOL bor = [[NSUserDefaults standardUserDefaults] objectForKey:@"islogined"];
//    if (!bor) {
//        self.taobaoButton.hidden = YES;
//    }
    //    BOOL bor = [[NSUserDefaults standardUserDefaults] objectForKey:@"islogined"];
    //    if (!bor) {
    //        self.taobaoButton.hidden = YES;
    //    }
}
- (void)IFneedWXLogin:(NSNotification *)notice{
    [self.createButton setTitle:@"知道了" forState:UIControlStateNormal];
@@ -108,15 +108,15 @@
    [self.navigationController pushViewController:merVC animated:YES];
}
- (void)boundCrate:(NSNotification *)notice{
//    NSLog(@"%@",notice.object);
//    self.boundDic = notice.object;
//    self.backView.hidden = NO;
//    [YTHsharedManger startManger].isBound = YES;
    //    NSLog(@"%@",notice.object);
    //    self.boundDic = notice.object;
    //    self.backView.hidden = NO;
    //    [YTHsharedManger startManger].isBound = YES;
    _isCreate = YES;
    [self.createButton setTitle:@"去创建" forState:UIControlStateNormal];
    self.primtLabel.text = @"您将使用刚才授权登录的账号";
    self.backView.hidden = NO;
}
- (void)isFirstLogin {
    
@@ -180,25 +180,25 @@
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(WeChatHasLoged:) name:@"PostWeChatLogin" object:nil];
        [[YTHsharedManger startManger] LogInForWeChat];
    }
//    [[YTHsharedManger startManger] LogInForFanliQuanWithLoginType:self.boundDic[@"type"] WithWXCode:self.boundDic[@"code"] create:@"1" uid:@"0" isfirst:NO block:^(BOOL isSuccessful, NSDictionary *dic) {
//        if (isSuccessful) {
//            NSMutableDictionary *tempDic=[NSMutableDictionary dictionaryWithCapacity:0];
//            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WeChatLogin"];
//            [tempDic setObject:@"1" forKey:@"isSuccessful"];
//            [SVProgressHUD showSuccessWithStatus:@"创建账号成功"];
//            [[NSNotificationCenter defaultCenter] postNotificationName:@"PostWeChatLogin" object:tempDic];
//            NSString *accountStr=[[[NSUserDefaults standardUserDefaults] objectForKey:@"userId"]stringValue];
////            [MiPushSDK setAlias:accountStr];
//
//        }else{
//            NSMutableDictionary *tempDic=[NSMutableDictionary dictionaryWithCapacity:0];
//            [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WeChatLogin"];
//            [tempDic setObject:@"0" forKey:@"isSuccessful"];
//            [SVProgressHUD showErrorWithStatus:@"创建账号失败"];
//            [[NSNotificationCenter defaultCenter] postNotificationName:@"PostWeChatLogin" object:tempDic];
//        }
//    }];
    //    [[YTHsharedManger startManger] LogInForFanliQuanWithLoginType:self.boundDic[@"type"] WithWXCode:self.boundDic[@"code"] create:@"1" uid:@"0" isfirst:NO block:^(BOOL isSuccessful, NSDictionary *dic) {
    //        if (isSuccessful) {
    //            NSMutableDictionary *tempDic=[NSMutableDictionary dictionaryWithCapacity:0];
    //            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WeChatLogin"];
    //            [tempDic setObject:@"1" forKey:@"isSuccessful"];
    //            [SVProgressHUD showSuccessWithStatus:@"创建账号成功"];
    //            [[NSNotificationCenter defaultCenter] postNotificationName:@"PostWeChatLogin" object:tempDic];
    //            NSString *accountStr=[[[NSUserDefaults standardUserDefaults] objectForKey:@"userId"]stringValue];
    ////            [MiPushSDK setAlias:accountStr];
    //
    //        }else{
    //            NSMutableDictionary *tempDic=[NSMutableDictionary dictionaryWithCapacity:0];
    //            [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WeChatLogin"];
    //            [tempDic setObject:@"0" forKey:@"isSuccessful"];
    //            [SVProgressHUD showErrorWithStatus:@"创建账号失败"];
    //            [[NSNotificationCenter defaultCenter] postNotificationName:@"PostWeChatLogin" object:tempDic];
    //        }
    //    }];
}
- (IBAction)boundTaped:(UIButton *)sender {
@@ -206,13 +206,13 @@
    self.isBound = YES;
    self.loginType = self.boundDic[@"type"];
    if ([self.loginType integerValue] == 2) {
//        self.wxButton.backgroundColor = [UIColor grayColor];
        //        self.wxButton.backgroundColor = [UIColor grayColor];
        self.wxButton.userInteractionEnabled = NO;
    }else{
        self.wxButton.userInteractionEnabled = YES;
    }
    if ([self.loginType integerValue] == 1) {
//        self.taobaoButton.backgroundColor = [UIColor grayColor];
        //        self.taobaoButton.backgroundColor = [UIColor grayColor];
        self.taobaoButton.userInteractionEnabled = NO;
    }else{
        self.taobaoButton.userInteractionEnabled = YES;
@@ -235,16 +235,18 @@
- (IBAction)LoginForTaoBao:(UIButton *)sender {
    [[YTHsharedManger startManger] LogInForTaoBaoWith:self Withblock:^(BOOL isSuccessful, NSDictionary *dic) {
        if (isSuccessful) {
            NSString *accountStr=[[[NSUserDefaults standardUserDefaults] objectForKey:@"userId"]stringValue];
//            [MiPushSDK setAlias:accountStr];
            //            [MiPushSDK setAlias:accountStr];
            [SVProgressHUD showSuccessWithStatus:@"返利券:登录成功"];
            [self loginDeviceToken];
            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"islogined"];
            [self.navigationController popViewControllerAnimated:NO];
        }else{
        } else {
            NSLog(@"");
        }
    }];
@@ -330,7 +332,7 @@
-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"PostWeChatLogin" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"boundOrCreate" object:nil];
}
@end
MIduo/½çÃæ/ÎÒµÄ/RedPacketDetailViewController.m
@@ -10,11 +10,13 @@
#import "RedPacketDetailTableViewCell.h"
@interface RedPacketDetailViewController ()<UITableViewDataSource,UITableViewDelegate>{
    int page;
    UITableView *_packetTableView;
}
@property (nonatomic , strong) NSMutableArray *orderList;//订单列表
@property (nonatomic, strong) NSMutableArray *orderList;//订单列表
/// åˆ†é¡µé¡µæ•°
@property (nonatomic, assign) NSInteger page;
@end
@@ -32,7 +34,8 @@
- (void)viewDidLoad {
    [super viewDidLoad];
    page=0;
    self.page = 0;
    
    //定制导航栏
    [self CreatNavigationBar];
@@ -61,26 +64,37 @@
 åŠ è½½æ•°æ®
 */
-(void)loadData{
    NSString *accountStr=[[NSUserDefaults standardUserDefaults] objectForKey:@"userId"];
    [[YTHNetInterface startInterface] getMoneyRecordWithUid:accountStr WithPage:[NSString stringWithFormat:@"%d",page] Withblock:^(BOOL isSuccessful, id result, NSString *error) {
    [[YTHNetInterface startInterface] getMoneyRecordWithUid:accountStr
                                                   WithPage:[NSString stringWithFormat:@"%ld",(long)self.page]
                                                  Withblock:^(BOOL isSuccessful, id result, NSString *error) {
        if (isSuccessful) {
            NSDictionary *dic = (NSDictionary *)result;
            if(!_orderList){
                _orderList=[[NSMutableArray alloc] initWithCapacity:0];
            if (!self.orderList) {
                self.orderList=[[NSMutableArray alloc] initWithCapacity:0];
            }
            
            if (page==0) {
                [_orderList removeAllObjects];
            if (self.page == 0) {
                [self.orderList removeAllObjects];
            }
            
            NSArray *arr = [[dic objectForKey:@"data"] objectForKey:@"moneyRecordList"];
            for (int i=0; i<arr.count; i++) {
                [_orderList addObject:[arr objectAtIndex:i]];
            for (int i = 0; i < arr.count; i++) {
                [self.orderList addObject:[arr objectAtIndex:i]];
            }
            if(_orderList.count>0){
                ++page;
            if (self.orderList.count > 0) {
                ++self.page;
            }
            [_packetTableView reloadData];
            [self->_packetTableView reloadData];
        }else{
            NSLog(@"请求失败");
        }