-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIView+CPTutorial.m
More file actions
executable file
·55 lines (47 loc) · 1.97 KB
/
UIView+CPTutorial.m
File metadata and controls
executable file
·55 lines (47 loc) · 1.97 KB
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
//
// UIView+CPTutorial.m
//
// Created by Can Poyrazoğlu on 23.11.14.
//
#import "CPTutorial.h"
#import "UIView+CPTutorial.h"
#import "CPTutorialInvisibleProxyView.h"
#import "CPTutorialTargetTouchIndicatorView.h"
@implementation UIView (CPTutorial)
-(CPTutorialBalloon*)displayBalloonTip:(NSString*)text afterPerforming:(CPTutorialAction)actionToExecuteBefore{
if([self isKindOfClass:[CPTutorialInvisibleProxyView class]] ||
[self isKindOfClass:[CPTutorialTargetTouchIndicatorView class]]){
if(!self.superview){
[[[[UIApplication sharedApplication] delegate] window] addSubview:self];
}
}
CPTutorialBalloon *balloon = [[CPTutorialBalloon alloc] initWithFrame:self.frame];
balloon.isManagedExternally = YES;
balloon.shouldResizeItselfAccordingToContents = YES;
balloon.text = text;
balloon.tutorial = [CPTutorial currentTutorial];
balloon.targetView = self;
balloon.blockToExecuteBeforeDisplaying = actionToExecuteBefore;
UIView *superviewToAddBalloon = [[[UIApplication sharedApplication] delegate] window];
[superviewToAddBalloon addSubview:balloon];
//now, a hacky way to "observe" frame changes:
self.autoresizesSubviews = YES;
CPTutorialInvisibleProxyView *proxyView = [CPTutorialInvisibleProxyView proxyView];
proxyView.delegate = balloon;
[self addSubview:proxyView];
return balloon;
}
-(CPTutorialBalloon*)displayBalloonTip:(NSString*)text{
return [self displayBalloonTip:text afterPerforming:nil];
}
-(CPTutorial*)displayBalloonTip:(NSString*)text onceWithIdentifier:(NSString*)tipName{
return [CPTutorial displayWithName:tipName actions:^{
[self displayBalloonTip:text];
}];
}
-(CPTutorial*)displayBalloonTip:(NSString*)text onceWithIdentifier:(NSString*)tipName afterPerforming:(CPTutorialAction)actionToExecuteBefore{
return [CPTutorial displayWithName:tipName actions:^{
[self displayBalloonTip:text afterPerforming:actionToExecuteBefore];
}];
}
@end