如何使用 Objective-C 在 ReactiveCocoa 中绑定结构
How to bind with struct in ReactiveCocoa with Objective-C
像这样满足特定条件我需要改变边框颜色,但我找不到通过编译器的方法:
RAC(self.addrTextField.layer, borderColor) = [validateAddressSignal map:^ CGColorRef* (NSArray *array) {
if (array.count) {
return [UIColor greenColor].CGColor;
}
return [UIColor clearColor].CGColor;
}];
Reactive Cocoa's GitHub Issue 跟踪器上提出的类似问题的最优雅解决方案是 Erik Price 发布的以下内容:
@interface UIView (MyCategoryName)
- (void)setMyBorderColor:(UIColor *)color;
@end
@implementation UIView
- (void)setMyBorderColor:(UIColor *)color
{
self.layer.borderColor = color.CGColor;
}
@end
// ...
RAC(myTextField, myBorderColor) = mySignalOfUIColors;
基本上,通过向 UIView 添加类别可以轻松绑定颜色。
像这样满足特定条件我需要改变边框颜色,但我找不到通过编译器的方法:
RAC(self.addrTextField.layer, borderColor) = [validateAddressSignal map:^ CGColorRef* (NSArray *array) {
if (array.count) {
return [UIColor greenColor].CGColor;
}
return [UIColor clearColor].CGColor;
}];
Reactive Cocoa's GitHub Issue 跟踪器上提出的类似问题的最优雅解决方案是 Erik Price 发布的以下内容:
@interface UIView (MyCategoryName)
- (void)setMyBorderColor:(UIColor *)color;
@end
@implementation UIView
- (void)setMyBorderColor:(UIColor *)color
{
self.layer.borderColor = color.CGColor;
}
@end
// ...
RAC(myTextField, myBorderColor) = mySignalOfUIColors;
基本上,通过向 UIView 添加类别可以轻松绑定颜色。