BeautyDrawer
BeautyDrawer 是一款簡單易用的抽屜效果實現框架,整合的屬效能夠對view 滑動縮放進行控制。
Main features
- 三個檢視,主檢視能夠左右滑動。實現抽屜效果
- 應用框架介面的內建引數屬效能夠對view的滑動速度。偏移度,和縮放比例進行設定
- 簡單易用
Demonstration
Requirements
- iOS 6.0+
- Xcode 6.1.1
Installation
手動匯入:
* 將BeautyDrawer/Resource
目錄中的全部檔案拽入專案中
* 匯入主標頭檔案<BeautyDrawer/ZHDrawerController.h>
API
Properties
/*
*主檢視隱藏後顯示比例(0~1) 是對主檢視大小縮放的屬性: 0.8
*/
@property (nonatomic, assign) CGFloat hideMainViewScale;
/**
*主檢視點選或拖拉恢復後比例 (0~1) 預設:1
*/
@property (nonatomic, assign) CGFloat backMainViewScale;
/*
*主檢視拖拽後centerX偏移比例,預設:0.05
*/
@property (nonatomic, assign) CGFloat centerDeviationX;
/*
*主檢視centerY偏移比例,預設:1
*/
@property (nonatomic, assign) CGFloat centerDeviationY;
/*
*滑動速度係數-建議在0.5-1之間。默覺得0.5
*/
@property (assign,nonatomic) CGFloat speed;
/*
*是否同意點選檢視恢復檢視位置。默覺得yes
*/
@property (strong) UITapGestureRecognizer *sideslipTapGes;
Method
不同的構造方法能夠實現不同檢視的格局
/*
*構造方法(左控制器 & 主控制器 &右控制器 & 背景圖片)
*/
- (instancetype)initWithLeftController:(UIViewController *)leftController
andMainController:(UIViewController *)mainController
andRightController:(UIViewController *)rightController
andBackgroundImage:(UIImage *)image;
/*
*構造方法(左控制器 & 主控制器 & 又控制器)
*/
- (instancetype)initWithLeftController:(UIViewController *)leftController
andMainController:(UIViewController *)mainController
andRightController:(UIViewController *)rightController;
/*
*構造方法(左控制器 & 主控制器)
*/
- (instancetype)initWithLeftController:(UIViewController *)leftController andMainView:(UIViewController *)mainController;
/*
*構造方法(右控制器 & 主控制器)
*/
- (instancetype)initWithRightView:(UIViewController *)rightController andMainView:(UIViewController *)mainController;
Usage
appdelegate 設定(required)
在appdelegate.m 檔案裡對檢視初始化
#import "AppDelegate.h"
#import "LeftViewController.h"
#import "MainViewController.h"
#import "RightViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 1. 建立window
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
// 2. 建立控制器
MainViewController *main = [[MainViewController alloc] init];
LeftViewController *left = [[LeftViewController alloc] init];
RightViewController *right = [[RightViewController alloc] init];
// 3. 建立跟控制器
self.controller = [[ZHDrawerController alloc] initWithLeftController:left andMainController:main andRightController:right];
self.controller.hideMainViewScale = 0.8;
self.controller.backMainViewScale = 1.0;
self.controller.centerDeviationX = 0.2;
// 4. 設定跟控制器
self.window.rootViewController = self.controller;
// 5. 顯示 window
[self.window makeKeyAndVisible];
return YES;
}
對檢視加入子view顯示
在leftView,rightView, mainView中自己定義view
- (void)viewDidLoad
{
[super viewDidLoad];
//不縮放 hideMainViewScale = 1.0
[self addImage];
//縮放 hideMainViewScale = 0.8
//[self loadAddView];
}
- (void)addImage
{
UIImageView *img = [[UIImageView alloc] initWithFrame:self.view.frame];
img.image = [UIImage imageNamed:@"main.jpg"];
[self.view addSubview:img];
}
GitHub
https://github.com/HuanDay/BeautyDrawer.git
致謝wangxiaoit童鞋