当is为真时,我有一堂课会调侃UIButton
's 。但是,在涉及和使用时也是如此。正在发生的事情是,由于某种原因,它正在对它们进行调配并在其后面添加自定义背景等。buttonType
UIButtonTypeCustom
UITableViewCellAccessoryCheckmark
UITableViewCellAccessoryDisclosure
accessoryType
我需要做的是检查UIButton
我试图调配的是否是 aUITableViewCellAccessoryType
但我不知道如何做这样的事情。
这是我用来调配UIButton
.
if ([self isMemberOfClass:[UIButton class]] && self.buttonType == UIButtonTypeCustom) {
UIImage *upImage = [theme rectButtonUp], *downImage = [theme rectButtonDown];
UIColor *upColor = [theme rectButtonUpTextColor], *downColor = [theme rectButtonDownTextColor];
/* If the highlighted title is set to _theme_asdf, look for a custom
* button image called "asdf" and use that. Clear out this highlighted
* title string. */
NSString *hlTitle = [self titleForState:UIControlStateHighlighted];
if ([hlTitle isEqualToString:@"_theme_add"] || [hlTitle isEqualToString:@"Add"]) {
upImage = [theme rectButtonUpAdd];
downImage = [theme rectButtonDownAdd];
} else if ([hlTitle isEqualToString:@"_theme_remove"]) {
upImage = [theme rectButtonUpRemove];
downImage = [theme rectButtonDownRemove];
} else {
upImage = [theme rectButtonUp];
downImage = [theme rectButtonDown];
}
[self setTitle:nil forState:UIControlStateHighlighted];
upColor = [theme rectButtonUpTextColor];
downColor = [theme rectButtonDownTextColor];
[self setBackgroundImage:upImage forState:UIControlStateNormal];
[self setBackgroundImage:downImage forState:UIControlStateHighlighted];
[self setBackgroundImage:downImage forState:UIControlStateSelected];
if (upColor) {
[self setTitleColor:upColor forState:UIControlStateNormal];
[self setTitleColor:[upColor colorByLighteningTo:0.5f] forState:UIControlStateDisabled];
}
if (downColor) {
[self setTitleColor:downColor forState:UIControlStateHighlighted];
[self setTitleColor:downColor forState:UIControlStateSelected];
}
}
任何帮助将不胜感激!