I am using SWRevealViewController in IOS app (universal). I'm getting sidebar in iPhone and iPad both but I want to show sidebar which covers 90% of screen - how can I?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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;
}
回答2:
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;
回答3:
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;
....
}
回答4:
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;