How to show resized sidebar using SWRevealViewController?

﹥>﹥吖頭↗ 提交于 2019-11-30 10:08:15

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

- (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;
}

Just have an if statement to determine the correct size of the sidebar. something like this:

if(device == iPad)
     _rearViewRevealWidth = 600.0f;
else if(device == iPhone)
     _rearViewRevealWidth = 260.0f;
Betsy

open the SWRevealViewController.m file 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;
....
}

You can do something like this... When you have subclass from SWRevealViewController... call property for this problem and set as you want... Hope it's help someone...

self.rightViewRevealWidth = [UIScreen mainScreen].bounds.size.width * 0.9;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!