点击主视图中的某个按钮,可以在右侧显示或者隐藏子视图,这种视图布局加载方式可用于,在主视图上需要加载一个子视图,用于对主视图内容的补充说明或者设置。仅支持iOS4以上版本,支持ARC或者Non-ARC。
主要是用到了PPRevealSideViewController这个类。下面举一个简单的例子,说明如何使用。
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, PPRevealSideViewControllerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) PPRevealSideViewController *revealSideViewController;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "MasterViewController.h"
@implementation AppDelegate
@synthesize revealSideViewController = _revealSideViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = PP_AUTORELEASE([[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]);
MasterViewController *main = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:main];
_revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav];
_revealSideViewController.delegate = self;
self.window.rootViewController = _revealSideViewController;
PP_RELEASE(main);
PP_RELEASE(nav);
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
@end
主视图中的按钮点击执行的方法
[self.revealSideViewController pushViewController:self.detailViewController onDirection:PPRevealSideDirectionRight withOffset:240.0f animated:YES];
子视图就是一个简单的表格,这里就不赘述了。
效果图:
分享到:
相关推荐
使用拓展与runtime,为UIView添加手势事件
UIView 动画 UIView动画
ios中关于uiview
UIView+Extension 对view的一个扩展
UIView AutoLayout ,UIView AutoLayout 是 UIView 的分类,实现了自动布局限制的简单接口。 T...
UIView+复制 用法 要运行示例项目, pod install克隆 repo,然后从 Example 目录运行pod install 。 #import <UIView> //If you need drawRect: drawing UIView *copiedView = [originalView pm_copy]; //if you ...
UIView-Positioning, 在UIView对象中,基于简单属性的框架属性设置 uiview定位收费 UIView Positioning 是一个快速扩展,它提供简单的shorthand 方法,以方便的方式定义任何UIView对象的框架属性( 宽度,高度,x,y ...
详细讲解UIView的生命循环周期,对开发者有更好的启发作用,深层次了解程序运行的流程。
1、将UIView 保存为图片,按照给定的scale 2、stackoverflow参照 3、保存的图片为依据scale,亲测
+ (UIView *_Nullable)az_gradientViewWithColors:(NSArray*> *_Nullable)colors locations:(NSArray*> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint; - (void)az_...
为UIView添加圆角扩展
已封装好的实现渐变的UIView,只需传入渐变开始值和结束值就可直接使用。有四种渐变方向可选
简单的把UIView转化为UIImage,大家可以看下。
本文通过实例代码给大家详细介绍了iOS UIView常见属性方法,非常不错,需要的朋友参考下吧
UIView 震动动画效果 AFViewShaker ,AFViewShaker 是一个简单的工具用来执行 。 使用方法: AFViewShaker *...
iOS中UIView的翻页动画demo 有几个是私有的api,小心使用。
通过协议扩展高斯模糊任意 UIView.zip,对任何具有swift协议扩展的uiview应用高斯模糊
iPhone开发学习笔记005——使用XIB自定义一个UIView,然后将这个view添加到controller的view。
uiview+frame,方便UI布局,码农工具,第一次上传,测下好用不
自定义NSLayoutConstraint约束库