How to show a modified sidebar using SWRevealViewController?

I am using SWRevealViewController in an IOS application (universal). I get a sidebar on the iPhone and iPad, but I want to show a sidebar that covers 90% of the screen - how can I?

+6
source share
4 answers

open the SWRevealViewController.m file and then get the _initDefaultProperties method. in this method you will get the size and position of the side screen.

 - (void)_initDefaultProperties { _frontViewPosition = FrontViewPositionLeft; _rearViewPosition = FrontViewPositionLeft; _rightViewPosition = FrontViewPositionLeft; _rearViewRevealWidth = 260.0f; /// this is the method u change the side bar width _rearViewRevealOverdraw = 60.0f; _rearViewRevealDisplacement = 40.0f; _rightViewRevealWidth = 260.0f; _rightViewRevealOverdraw = 60.0f; _rightViewRevealDisplacement = 40.0f; _bounceBackOnOverdraw = YES; _bounceBackOnLeftOverdraw = YES; _stableDragOnOverdraw = NO; _stableDragOnLeftOverdraw = NO; _presentFrontViewHierarchically = NO; _quickFlickVelocity = 250.0f; _toggleAnimationDuration = 0.25; _frontViewShadowRadius = 2.5f; _frontViewShadowOffset = CGSizeMake(0.0f, 2.5f); _frontViewShadowOpacity = 1.0f; _userInteractionStore = YES; _animationQueue = [NSMutableArray array]; _draggableBorderWidth = 0.0f; } 
+13
source

Just specify an if statement to determine the correct size of the sidebar. something like that:

 if(device == iPad) _rearViewRevealWidth = 600.0f; else if(device == iPhone) _rearViewRevealWidth = 260.0f; 
+2
source

open the file SWRevealViewController.m and then you get the _initDefaultProperties method.

  - (void)_initDefaultProperties { AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; float x=(appDelegate.windowWidth)*9/10; //windowWidth=self.window.bounds.size.width; float y=x-260; _frontViewPosition = FrontViewPositionLeft; _rearViewPosition = FrontViewPositionRightMost; _rightViewPosition = FrontViewPositionLeft; _rearViewRevealWidth = x; _rearViewRevealOverdraw = 60.0f+y; _rearViewRevealDisplacement = 40.0f+y; .... } 
+1
source

You can do something like this ... When you have a subclass from SWRevealViewController ... call the property for this problem and set how you want ... Hope this helps someone ...

 self.rightViewRevealWidth = [UIScreen mainScreen].bounds.size.width * 0.9; 
0
source

Source: https://habr.com/ru/post/973473/


All Articles