/
ViewController.m
65 lines (57 loc) · 2.97 KB
/
ViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#import <QuartzCore/QuartzCore.h>
#import "ViewController.h"
#import "JWFolders.h"
@implementation ViewController
@synthesize sampleFolder = _sampleFolder;
- (void)viewDidLoad {
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"wallpaper"]];
self.sampleFolder = [[FolderViewController alloc] initWithNibName:NSStringFromClass([FolderViewController class]) bundle:nil];
}
#pragma mark - Folder Example
- (IBAction)openFolderUp:(id)sender {
NSLog(@"Folder will open up.");
CGPoint openPoint = CGPointMake(0, CGRectGetHeight(self.view.frame) / 2); //arbitrary point
[JWFolders openFolderWithContentView:self.sampleFolder.view
position:openPoint
containerView:self.view
openBlock:^(UIView *contentView, CFTimeInterval duration, CAMediaTimingFunction *timingFunction) {
//perform custom animation here on contentView if you wish
NSLog(@"Folder view: %@ is opening with duration: %f", contentView, duration);
}
closeBlock:^(UIView *contentView, CFTimeInterval duration, CAMediaTimingFunction *timingFunction) {
//also perform custom animation here on contentView if you wish
NSLog(@"Folder view: %@ is closing with duration: %f", contentView, duration);
}
completionBlock:^ {
//the folder is closed and gone, lets do something cool!
NSLog(@"Folder view is closed.");
}
direction:JWFoldersOpenDirectionUp
];
}
- (IBAction)openFolderDown:(id)sender {
NSLog(@"Folder will open down.");
CGPoint openPoint = CGPointMake(0, CGRectGetHeight(self.view.frame) / 2); //arbitrary point
// you can also open the folder this way
// it could be potentially easier if you don't need the blocks
JWFolders *folder = [JWFolders folder];
folder.contentView = self.sampleFolder.view;
folder.containerView = self.view;
folder.position = openPoint;
folder.direction = JWFoldersOpenDirectionDown;
folder.transparentPane = YES;
[folder open];
// quick demo to demonstrate how the stationary pane is see-though
[UIView animateWithDuration:0.3f animations:^{
[(UIButton *)sender setTransform:CGAffineTransformRotate([(UIButton *)sender transform], M_PI*0.1f)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3f animations:^{
[(UIButton *)sender setTransform:CGAffineTransformRotate(CGAffineTransformIdentity, -M_PI*0.1f)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3f animations:^{
[(UIButton *)sender setTransform:CGAffineTransformIdentity];
}];
}];
}];
}
@end