Subclassing a UILabel, Given a Warning
I have the following at the top of one of my UIViewControllers.m:
@implementation UILabel (Custom)
-(void)setTitleLabelColor
{
UIColor *titleColor = [UIColor colorWithRed:1 green:0.90196 blue:0 alpha:1.0];
self.textColor = titleColor;
}
@end
I basically want to have a method that makes the text color to yellow.
When I call that function, it always gives me a warning, saying the UILabel might not respond to it, but it works fine.
How can I get rid of the warni开发者_开发问答ngs?
You should also declare this in your header (.h
) file. For example,
@interface UILabel (Custom)
-(void)setTitleLabelColor;
@end
Then #import
this from another file when you want to use that method.
精彩评论