1

Is it possible to create categories to define custom additional methods for existing iOS classes and controls in Delphi/FMX (like in Xcode, without subclassing?

For example, i want to change the appearance of UILabel, especialy the text alignment of them, within a UIAlertContoller class. In Xcode I would simply create a neu category for UILabel with a new method:

@interface UILabel (TextAppearance) @property (nonatomic, assign) NSTextAlignment appearanceAlignment UI_APPEARANCE_SELECTOR;
@end

@ implementation UILabel (TextAppearance)

-(void)setAppearanceAlignment(NSTextAlignment)alignment {
    [self setTextAlignment:alignment]; }

-(NSTextAlignment)appearanceAlignment {
    return self.textAlignment; }

@end

How can I do the same with Delphi/FMX?

Neha Gupta
  • 539
  • 3
  • 13
vitaliy-zh
  • 185
  • 9
  • To make long story short, yes you can extend class adding additional methods using class helpers - that is what this feature us called in Delphi, but you can only have single class helper in scope. – Dalija Prasnikar Sep 06 '17 at 08:13

0 Answers0