Может кто-нибудь помочь мне переписать этот код в быстройObjC блок в стремительной
[segmentedControl1 setTitleFormatter:^NSAttributedString *(HMSegmentedControl *segmentedControl, NSString *title, NSUInteger index, BOOL selected) {
NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName : [UIColor blueColor]}];
return attString;
}];
Часть класса HMSegmentedControl:
@interface HMSegmentedControl : UIControl
....
@property (nonatomic, copy) HMTitleFormatterBlock titleFormatter;
....
@end
typedef NSAttributedString *(^HMTitleFormatterBlock)(HMSegmentedControl *segmentedControl, NSString *title, NSUInteger index, BOOL selected);
Мой код:
segmentedControl1.titleFormatter = {(segmentedControl: HMSegmentedControl, title: NSString, index: Int, selected: Bool) -> NSAttributedString in
}
я получаю error: "'(HMSegmentedControl, NSString, Int, Bool) -> NSAttributedString' не конвертируется в 'HMTitleFormatterBlock'"
Можете ли вы показать код, который объявляет свойство 'titleFormatter'? – wltrup
Это показано выше. titleFormatter - свойство HMSegmentedControl – Ilya