通知中心传参
作者:
精神薇 | 来源:发表于
2018-02-08 23:15 被阅读0次NSDictionary *dict = @{@"color":color, @"userName":@"haha"};
[[NSNotificationCenter defaultCenter] postNotificationName:@"changeBgColor" object:nil userInfo:dict];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeBgColor:) name:@"changeBgColor" object:nil];
- (void)changeBgColor:(NSNotification *)notification{
NSLog(@"接受到通知,改变背景颜色");
// 如果是传多个数据,那么需要哪个数据,就对应取出对应的数据即可
self.view.backgroundColor = notification.userInfo[@"color"];
UILabel *label = (UILabel *)[self.view viewWithTag:100];
label.text = notification.userInfo[@"userName"];
}
本文标题:通知中心传参
本文链接:https://www.haomeiwen.com/subject/znvxtftx.html
网友评论