1.按钮addTarget
[[self.aDepositBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { //点击处理 }]; |
2.View加tap事件
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init]; @weakify(self); [[tap rac_gestureSignal] subscribeNext:^(id x) { @strongify(self); }]; [infoView addGestureRecognizer:tap]; |
3.KVO监听对象的某个属性
[RACObserve(self.mobileTextField, text) subscribeNext:^(id _Nullable x) { NSString * text = (NSString *)x; if (text.length) { //将提交按钮置为蓝色
} else { //将提交按钮置为灰色 } }]; |
4.通知传值
[[NSNotificationCenter defaultCenter] postNotificationName:@"RACNotification" object:@[@"1",@"2"]]; |
[[[NSNotificationCenter defaultCenter]rac_addObserverForName:@"RACNotification" object:nil]subscribeNext:^(id x) { NSLog(@"%@",x); }]; |
5.UITextField输入结束等类似的代理方法
[[self.textField rac_signalForControlEvents:UIControlEventEditingDidEnd] subscribeNext:^(id x){ //x是textField对象 NSLog(@"%@",x); }]; |