Last active
December 28, 2015 07:49
-
-
Save 7gano/7467325 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "RCViewController.h" | |
@import QuartzCore; | |
@implementation RCViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
CGRect rect; | |
rect = CGRectMake(50, 50, 200, 200); | |
UIView *view0 = [[UIView alloc] initWithFrame:rect]; | |
view0.backgroundColor = [UIColor redColor]; | |
view0.tag = 0; | |
[self.view addSubview:view0]; | |
rect.origin.x = 100; | |
rect.origin.y = 100; | |
UIView *view1 = [[UIView alloc] initWithFrame:rect]; | |
view1.backgroundColor = [UIColor blueColor]; | |
view1.tag = 1; | |
[self.view addSubview:view1]; | |
double delayInSeconds = 1.0; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
//view0を見かけ上、前に出す | |
view0.layer.zPosition = 1; | |
}); | |
UITapGestureRecognizer *recognizer; | |
recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_tapAction:)]; | |
[view0 addGestureRecognizer:recognizer]; | |
recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_tapAction:)]; | |
[view1 addGestureRecognizer:recognizer]; | |
} | |
- (void)_tapAction:(UITapGestureRecognizer*)recognizer | |
{ | |
if (recognizer.view.tag == 0) { | |
NSLog(@"赤でしょ!"); | |
} else if (recognizer.view.tag == 1) { | |
NSLog(@"青でしょ!"); | |
} else { | |
NSLog(@"今でしょ!"); | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment