19
19
#define kAnimatedOffsetFactorLeft 0 .5f
20
20
#define kAnimatedOffsetFactorRight 0 .5f
21
21
#define kDimViewMaxAlpha 0 .5f
22
+ #define kDefaultBottomViewHeight 45 .0f
22
23
23
24
typedef NS_ENUM (NSInteger , CHSlideDirection)
24
25
{
@@ -54,6 +55,8 @@ @interface CHSlideController () <UIGestureRecognizerDelegate>
54
55
55
56
UIView *statusBar;
56
57
58
+ CGFloat defaultViewHeight;
59
+
57
60
}
58
61
59
62
@property (nonatomic , strong ) UIView *leftSafeAreaView;
@@ -421,6 +424,29 @@ -(void)setSlidingViewController:(UIViewController *)slidingViewController
421
424
}
422
425
}
423
426
427
+ -(void )setBottomView : (UIView *)bottomView
428
+ {
429
+ [self setBottomView: bottomView withHeight: kDefaultBottomViewHeight ];
430
+ }
431
+
432
+ -(void )setBottomView : (UIView *)bottomView withHeight : (CGFloat)bottomViewHeight
433
+ {
434
+ // TODO: implement
435
+
436
+ [_bottomView removeFromSuperview ];
437
+ _bottomView = nil ;
438
+
439
+ defaultViewHeight = bottomViewHeight;
440
+
441
+ _bottomView = bottomView;
442
+
443
+ if (_bottomView != nil ) {
444
+ [self .view addSubview: _bottomView];
445
+ }
446
+
447
+ [self CH_layoutForOrientation ];
448
+ }
449
+
424
450
-(void )setLeftStaticViewWidth : (CGFloat)staticViewWidth
425
451
{
426
452
@@ -648,11 +674,18 @@ - (void)CH_layoutForOrientation
648
674
}
649
675
650
676
677
+ CGFloat contentHeight;
678
+
679
+ if (_bottomView == nil ) {
680
+ contentHeight = self.view .bounds .size .height ;
681
+ }else {
682
+ contentHeight = self.view .bounds .size .height -defaultViewHeight;
683
+ }
651
684
652
685
653
686
// setting desired frames
654
- _leftStaticView.frame = CGRectMake (0 , 0 , cuttedOffLeftStaticWidth, self. view . bounds . size . height );
655
- _rightStaticView.frame = CGRectMake (self.view .bounds .size .width -cuttedOffRightStaticWidth, 0 , cuttedOffRightStaticWidth, self. view . bounds . size . height );
687
+ _leftStaticView.frame = CGRectMake (0 , 0 , cuttedOffLeftStaticWidth, contentHeight );
688
+ _rightStaticView.frame = CGRectMake (self.view .bounds .size .width -cuttedOffRightStaticWidth, 0 , cuttedOffRightStaticWidth, contentHeight );
656
689
657
690
// initialLeftStaticViewFrame = _leftStaticView.frame;
658
691
// initialRightStaticViewFrame = _rightStaticView.frame;
@@ -668,22 +701,22 @@ - (void)CH_layoutForOrientation
668
701
_tapRecognizer.enabled = YES ;
669
702
// Static view is uncovered
670
703
671
- _slidingView.frame = CGRectMake (leftStaticWidth, 0 , slidingWidth, self. view . bounds . size . height );
704
+ _slidingView.frame = CGRectMake (leftStaticWidth, 0 , slidingWidth, contentHeight );
672
705
673
706
}else if (isRightStaticViewVisible) {
674
707
_tapRecognizer.enabled = YES ;
675
- _slidingView.frame = CGRectMake (_rightStaticView.frame .origin .x -slidingWidth, 0 , slidingWidth, self. view . bounds . size . height );
708
+ _slidingView.frame = CGRectMake (_rightStaticView.frame .origin .x -slidingWidth, 0 , slidingWidth, contentHeight );
676
709
677
710
}else {
678
711
_tapRecognizer.enabled = NO ;
679
712
// Static view is covered
680
- _slidingView.frame = CGRectMake (0 , 0 , slidingWidth, self. view . bounds . size . height );
713
+ _slidingView.frame = CGRectMake (0 , 0 , slidingWidth, contentHeight );
681
714
682
715
683
- _leftStaticView.frame = CGRectMake (_slidingView.frame .origin .x -_leftStaticViewWidth+((_leftStaticViewWidth-_slidingView.frame .origin .x )*_leftAnimationSlidingAnimationFactor), 0 , _leftStaticViewWidth, self. view . bounds . size . height );
716
+ _leftStaticView.frame = CGRectMake (_slidingView.frame .origin .x -_leftStaticViewWidth+((_leftStaticViewWidth-_slidingView.frame .origin .x )*_leftAnimationSlidingAnimationFactor), 0 , _leftStaticViewWidth, contentHeight );
684
717
685
718
686
- _rightStaticView.frame = CGRectMake ((_slidingView.frame .origin .x +_slidingView.frame .size .width )+((-1 *(_slidingView.frame .origin .x +_rightStaticViewWidth))*_rightAnimationSlidingAnimationFactor), 0 , _leftStaticViewWidth, self. view . bounds . size . height );
719
+ _rightStaticView.frame = CGRectMake ((_slidingView.frame .origin .x +_slidingView.frame .size .width )+((-1 *(_slidingView.frame .origin .x +_rightStaticViewWidth))*_rightAnimationSlidingAnimationFactor), 0 , _leftStaticViewWidth, contentHeight );
687
720
688
721
689
722
@@ -706,12 +739,12 @@ - (void)CH_layoutForOrientation
706
739
707
740
if (!isLeftStaticViewVisible && !isRightStaticViewVisible) {
708
741
_leftSafeAreaView.frame = CGRectMake (0 , 0 , 15 , _slidingView.bounds .size .height );
709
- _rightSafeAreaView.frame = CGRectMake (_slidingView.bounds .size .width -15 , 0 , 15 , self. view . bounds . size . height );
742
+ _rightSafeAreaView.frame = CGRectMake (_slidingView.bounds .size .width -15 , 0 , 15 , contentHeight );
710
743
}else {
711
744
712
745
if (isLeftStaticViewVisible) {
713
746
_leftSafeAreaView.frame = CGRectMake (0 , 0 , fabs (_slidingView.bounds .size .width -_leftStaticView.bounds .size .width ), _slidingView.bounds .size .height );
714
- _rightSafeAreaView.frame = CGRectMake (_slidingView.bounds .size .width -0 , 0 , 0 , self. view . bounds . size . height );
747
+ _rightSafeAreaView.frame = CGRectMake (_slidingView.bounds .size .width -0 , 0 , 0 , contentHeight );
715
748
}
716
749
717
750
if (isRightStaticViewVisible) {
0 commit comments