Skip to content

Commit 0c56b9b

Browse files
author
Clemens
committed
implemented bottom view and iphone x adoptions
1 parent 36f2dcc commit 0c56b9b

File tree

6 files changed

+68
-19
lines changed

6 files changed

+68
-19
lines changed

CHSlideController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'CHSlideController'
3-
s.version = '2.7.6'
3+
s.version = '2.8'
44
s.platform = :ios, '8.1'
55
s.license = 'MIT'
66
s.summary = 'A ViewController that manages 3 contained viewcontrollers'

CHSlideController/CHSlideController-Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
<key>CFBundlePackageType</key>
2020
<string>APPL</string>
2121
<key>CFBundleShortVersionString</key>
22-
<string>2.7.6</string>
22+
<string>2.8</string>
2323
<key>CFBundleSignature</key>
2424
<string>????</string>
2525
<key>CFBundleVersion</key>
26-
<string>499</string>
26+
<string>510</string>
2727
<key>LSRequiresIPhoneOS</key>
2828
<true/>
2929
<key>UILaunchStoryboardName</key>

CHSlideController/CHSlideController/CHSlideController.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
*/
7575
@property (strong, nonatomic) UIViewController *slidingViewController;
7676

77+
/**
78+
* A view that is displayed on the bottom (can be used for progress bar or similar things)
79+
*/
80+
@property (strong, nonatomic) UIView *bottomView;
81+
7782
/**
7883
* If set to yes a shadow will be drawn under the slidingView. Defaults to YES
7984
*/
@@ -144,15 +149,16 @@
144149
-(void)setLeftStaticViewWidth:(CGFloat)leftStaticViewWidth animated:(BOOL)animated;
145150
-(void)setRightStaticViewWidth:(CGFloat)rightStaticViewWidth animated:(BOOL)animated;
146151

152+
-(void)setBottomView:(UIView *)bottomView withHeight:(CGFloat)bottomViewHeight;
153+
147154
/*
148155
Value between 0.0f and 1.0f
149156
150157
0.0 = slide with sliding view
151158
>0.0<1.0 = like swipe back in uinavigationcontroller
152159
1.0 = dont slide at all - slideview covers static views
153-
154-
155160
*/
161+
156162
@property (nonatomic, assign) CGFloat leftAnimationSlidingAnimationFactor;
157163
@property (nonatomic, assign) CGFloat rightAnimationSlidingAnimationFactor;
158164

CHSlideController/CHSlideController/CHSlideController.m

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define kAnimatedOffsetFactorLeft 0.5f
2020
#define kAnimatedOffsetFactorRight 0.5f
2121
#define kDimViewMaxAlpha 0.5f
22+
#define kDefaultBottomViewHeight 45.0f
2223

2324
typedef NS_ENUM(NSInteger, CHSlideDirection)
2425
{
@@ -54,6 +55,8 @@ @interface CHSlideController () <UIGestureRecognizerDelegate>
5455

5556
UIView *statusBar;
5657

58+
CGFloat defaultViewHeight;
59+
5760
}
5861

5962
@property (nonatomic, strong) UIView *leftSafeAreaView;
@@ -421,6 +424,29 @@ -(void)setSlidingViewController:(UIViewController *)slidingViewController
421424
}
422425
}
423426

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+
424450
-(void)setLeftStaticViewWidth:(CGFloat)staticViewWidth
425451
{
426452

@@ -648,11 +674,18 @@ - (void)CH_layoutForOrientation
648674
}
649675

650676

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+
}
651684

652685

653686
// 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);
656689

657690
// initialLeftStaticViewFrame = _leftStaticView.frame;
658691
//initialRightStaticViewFrame = _rightStaticView.frame;
@@ -668,22 +701,22 @@ - (void)CH_layoutForOrientation
668701
_tapRecognizer.enabled = YES;
669702
// Static view is uncovered
670703

671-
_slidingView.frame = CGRectMake(leftStaticWidth, 0, slidingWidth, self.view.bounds.size.height);
704+
_slidingView.frame = CGRectMake(leftStaticWidth, 0, slidingWidth, contentHeight);
672705

673706
}else if (isRightStaticViewVisible) {
674707
_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);
676709

677710
}else {
678711
_tapRecognizer.enabled = NO;
679712
// Static view is covered
680-
_slidingView.frame = CGRectMake(0, 0, slidingWidth, self.view.bounds.size.height);
713+
_slidingView.frame = CGRectMake(0, 0, slidingWidth, contentHeight);
681714

682715

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);
684717

685718

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);
687720

688721

689722

@@ -706,12 +739,12 @@ - (void)CH_layoutForOrientation
706739

707740
if (!isLeftStaticViewVisible && !isRightStaticViewVisible) {
708741
_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);
710743
}else {
711744

712745
if (isLeftStaticViewVisible) {
713746
_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);
715748
}
716749

717750
if (isRightStaticViewVisible) {

CHSlideController/CHStaticDemo.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ - (instancetype)initWithStyle:(UITableViewStyle)style
2020
if (self) {
2121

2222
// Create some dummy data
23-
_data = @[@"Test 1",@"Test 2",@"Test 3",@"Hide Statusbar",@"Hide Navigationbar", @"Shadow ON/OFF",@"Change Width",@"DIM ON/OFF"];
23+
_data = @[@"Test 1",@"Test 2",@"Test 3",@"Hide Statusbar",@"Hide Navigationbar", @"Shadow ON/OFF",@"Change Width",@"DIM ON/OFF",@"Toggle Bottom View"];
2424

2525
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
2626
//self.searchController.searchResultsUpdater = self;

CHSlideController/DemoSlideControllerSubclass.m

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,20 @@ -(void)staticDemoDidSelectText:(NSString *)text
182182

183183
self.dimSlidingViewWhenNoCoveringStaticView = !self.dimSlidingViewWhenNoCoveringStaticView;
184184

185-
}
186-
187-
// [self.view setNeedsLayout];
188-
185+
}else if ([text isEqualToString:@"Toggle Bottom View"]) {
186+
187+
188+
if (self.bottomView == nil) {
189+
UIView *testBottomView = [[UIView alloc] init];
190+
testBottomView.backgroundColor = [UIColor blueColor];
191+
[self setBottomView:testBottomView];
192+
}else {
193+
[self setBottomView:nil];
194+
}
195+
196+
197+
198+
}
189199

190200
}
191201

0 commit comments

Comments
 (0)