开发者

Subclassing a UILabel, Given a Warning

开发者 https://www.devze.com 2023-03-29 17:41 出处:网络
I have the following at the top of one of my UIViewControllers.m: @implementation UILabel (Custom) -(void)setTitleLabelColor

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号