前端之家收集整理的这篇文章主要介绍了
ReactiveCocoa系列-隐藏显示placehold,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//创建textField获得焦点信号,当信号发生时返回@YES
RACSignal *didBeginEditingSignal = [[self rac_signalForSelector:@selector(textFieldDidBeginEditing:) fromProtocol:@protocol(UITextFieldDelegate)] mapReplace:@YES];
//创建textField失去焦点信号,当信号发生时返回@NO
RACSignal *didEndEditingSignal = [[self rac_signalForSelector:@selector(textFieldDidEndEditing:) fromProtocol:@protocol(UITextFieldDelegate)] mapReplace:@NO];
//合并两种信号到一个信号
RACSignal *userTextSignal = [RACSignal merge:@[didBeginEditingSignal,didEndEditingSignal]];
//doNext是信号发生时注入的边界触发.hiden为label的属性
RAC(placehold,hidden) = [userTextSignal doNext:^(id x) {
NSLog(@"toggle placehold. %@",x);
}];