【发布时间】:2014-09-30 07:25:16
【问题描述】:
我在 IOS 应用程序(通用)中使用 SWRevealViewController。我在 iPhone 和 iPad 上都有侧边栏,但我想显示覆盖 90% 屏幕的侧边栏 - 我该怎么做?
【问题讨论】:
-
它总是覆盖 90% 的视图,你能显示你需要的屏幕截图吗
标签: ios objective-c iphone swift swrevealviewcontroller
我在 IOS 应用程序(通用)中使用 SWRevealViewController。我在 iPhone 和 iPad 上都有侧边栏,但我想显示覆盖 90% 屏幕的侧边栏 - 我该怎么做?
【问题讨论】:
标签: ios objective-c iphone swift swrevealviewcontroller
打开SWRevealViewController.m文件,然后得到_initDefaultProperties方法。
- (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;
....
}
【讨论】:
你可以做这样的事情...... 当您拥有 SWRevealViewController 的子类时... 为此问题调用属性并根据需要进行设置... 希望对某人有所帮助...
self.rightViewRevealWidth = [UIScreen mainScreen].bounds.size.width * 0.9;
【讨论】:
只需一个 if 语句来确定侧边栏的正确大小。像这样:
if(device == iPad)
_rearViewRevealWidth = 600.0f;
else if(device == iPhone)
_rearViewRevealWidth = 260.0f;
【讨论】:
打开SWRevealViewController.m 文件,然后你会得到_initDefaultProperties 方法。在这种方法中,您可以获得侧屏尺寸和位置
- (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;
}
【讨论】: