#import "CYViewController.h"
@interface CYViewController ()
@property (nonatomic,copy,readonly) CYViewController *(^funcA)(NSString *str);
@property (nonatomic,copy,readonly) CYViewController *(^setColor)(UIColor *color);
@property (nonatomic,strong)UILabel *testLabel;
@end
@implementation CYViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_testLabel = [UILabel new];
[_testLabel setBackgroundColor:[UIColor darkGrayColor]];
[_testLabel setFrame:CGRectMake(20, 100, 200, 40)];
[self.view addSubview:_testLabel];
// 链式调用
self.funcA(@"哈哈哈").setColor([UIColor whiteColor]);
}
- (CYViewController *(^)(UIColor *))setColor{
return ^(UIColor *color){
self.testLabel.textColor = color;
return self;
};
}
- (CYViewController *(^)(NSString *))funcA{
return ^(NSString *str){
[self.testLabel setText:str];
return self;
};
}
@end
网友评论