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
| // RootViewController.m -(void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor redColor]; UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.tag = 101; button.frame = CGRectMake(320/2-140/2,200,140,40); [button setTile:@"进入" forState:UIControlStateNormal]; [button addTarget:self action:@selector(presentModalVC) forControlEvent:UIControlEventTouchUpInside]; [self.view addSubiew:button]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(90,100,140,40)]; label.text = @"hello world"; label.tag = 102; label.textAligment = NSTextAligmentCenter; [self.view addSubView:label]; } -(void)presentModalVC { ModalViewController *modalVc = [[ModalViewController alloc] init]; modalVc.delegate = self; // 动画效果 modalVc.modalTranstionSyle = UIModalTransitionStylePatialCurl; if([[UIDevice currentDevice].systemVersion floatValue] < 6.0){ [self.presentModalViewController:modalVc animated:YES]; }else{ [self.presentModalViewController:modalVc animated:YES completion:^{ NSLog(@"call back"); }]; [modalVC relese]; } } -(void)changeLabelText:(NSString *)text { UILabel *label = (UILable *)[self.view viewWithTag:102]; label.text = text; }
|