Block作為屬性,其他控制器調(diào)用時(shí)
@property (nonatomic, strong) int (^ChangeBackgroundImage)(int mark);
返回值:int Block名字:ChangeBackgroundImage 傳入的參數(shù):mark
block里面的實(shí)現(xiàn)內(nèi)容如下:
// 實(shí)現(xiàn)block里面的內(nèi)容:
self.ChangeBackgroundImage = ^(int mark) {
// 這里可以加一些操作 或者其他的...
weakSelf.baseImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpeg", mark]];
// imageMark = mark;
// 如果有參數(shù) return就行
return mark;
};
block在其他控制器調(diào)用的時(shí)候:
self.ChangeBackgroundImage(mark);