はじめに
ビンゴ中西です。
jwilling/JWFolders · GitHub
を試してみました。
Viewがうわーっと割れて中のViewがひょっこり現れる仕組みです。
準備!
githubからJWFoldersディレクトリーをあなたのプロジェクトに入れよう!
QuartzCore.frameworkをXcodeから入れよう!
.hはこんな感じ!
1
2
3
4
5
6
7
8
|
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic, strong) IBOutlet UIView *contentView;
@property(nonatomic, weak) IBOutlet UILabel *sampleLabel;
@end
|
.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
|
#import “ViewController.h”
#import “JWFolders.h”
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(IBAction)pressSeparate:(id)sender{
CGPoint openPoint = CGPointMake(CGRectGetWidth(self.view.frame) / 2, [sender frame].origin.y - 20);
JWFolders *folder = [JWFolders folder];
folder.contentView = self.contentView;
folder.containerView = self.view;
folder.position = openPoint;
folder.direction = JWFoldersOpenDirectionUp;
folder.contentBackgroundColor = [UIColor blueColor];
folder.shadowsEnabled = NO;
folder.showsNotch = NO;
[folder open]; // opens the folder.
}
-(IBAction)changeLabel:(id)sender{
self.sampleLabel.text = @“BBBBB”;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
|
.xibはこんな感じ
考察
さてこれ、動画からもわかってもらえると思うのですが、
開いた後に見える中のボタンで、UILabelの文字列を変える処理を走らせています。
でも、Viewが割れた段階で、UILabelが載っているように見えているViewは単なる画像になってしまっています。
ですので、UILabelの値が更新されたように見えるのはViewが閉じたあとになってしまいます。
なので、中(contentView)から外(containerView)を操作するような処理は書かない方がよいかと思います(アニメーションしないので)。