Вам нужно написать такой метод:
- (void) changeBackgroundColorOfElement:(NSObject *) element toColour:(UIColor *) color {
if ([element respondsToSelector:@selector(backgroundColor)]) [element setBackgroundColor:color];
else if ([element respondsToSelector:@selector(tintColor)]) [element setTintColor:color];
}
, который можно вызвать по:
[self changeBackgroundColorOfElement:myLabel toColour:[UIColor blackColor]];
Или вы можете использовать метод C, который вы бы назвали так же, как ваш код PHP:
void changeBackgroundColorOfElementToColour(NSObject *element, UIColor *color) {
if ([element respondsToSelector:@selector(backgroundColor)]) [element setBackgroundColor:color];
else if ([element respondsToSelector:@selector(tintColor)]) [element setTintColor:color];
}