I'm making a simple UIButton subclass.
.h file:
@interface VUFollowButton : UIButton
/**
Designated initializer
@param follow Highlights the button if true
*/
+ (instancetype)buttonWithFollow:(BOOL)follow;
/*
* Setting this bool to YES will highlight the button and change the text to "following"
* Default is "follow"
*/
@property (nonatomic, assign) BOOL following;
@end
.m file:
#import "VUFollowButton.h"
@implementation VUFollowButton
+ (instancetype)buttonWithFollow:(BOOL)follow {
VUFollowButton* followButton = (VUFollowButton*)[UIButton buttonWithType:UIButtonTypeCustom];
[followButton setTitleEdgeInsets:UIEdgeInsetsMake(2., 8., 2., 8.)];
followButton.layer.borderColor = [UIColor whitColor];
followButton.layer.borderWidth = 2.0f;
[followButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
followButton.titleLabel.font = [UIFont nationalBoldWithSize:17];
followButton.following = follow;
return followButton;
}
- (void)setFollowing:(BOOL)following {
if (!following) {
self.backgroundColor = [UIColor clearColor];
[self setTitle:@"FOLLOW" forState:UIControlStateNormal];
}
else {
self.backgroundColor = [UIColor blackColor];
[self setTitle:@"FOLLOWING" forState:UIControlStateNormal];
}
}
@end
But on the line followButton.following = follow;
, I'm getting:
-[UIButton setFollowing:]: unrecognized selector sent to instance 0x7f9c10f809b0
If I set a breakpoint before that line, followButton
shows as a VUFollowButton
in the variable debugger and has a property called following
.
I know I'm missing something basic here.