版权所有,禁止匿名转载;禁止商业使用。
#import <UIKit/UIKit.h>
@interface TwoViewController : UIViewController
@property (nonatomic,copy)void(^_changeColorBlock)(UIColor *);
@end
#import "TwoViewController.h"
- (IBAction)goto1:(UIButton *)sender {
UIColor *color = sender.tag == 1?[UIColor redColor]:sender.tag == 2?[UIColor greenColor]:[UIColor blueColor];
__changeColorBlock(color);
[self.navigationController popViewControllerAnimated:YES];
}
#import "OneViewController.h"
- (IBAction)goto2:(id)sender {
TwoViewController *vc = [[TwoViewController alloc]init];
void (^block)(UIColor *) = ^(UIColor *color){
self.view.backgroundColor = color;
};
vc._changeColorBlock = block;
[self.navigationController pushViewController:vc animated:YES];
}