buttonType
이 UIButtonTypeCustom
일 때 UIButton
이 깜박 거리는 클래스가 있습니다. 그러나 UITableViewCellAccessoryCheckmark
및 UITableViewCellAccessoryDisclosure
도 마찬가지입니다. 무슨 일이 일어나고 있는지 어떤 이유인지, 그것은 무엇인가 이유 때문에 그것들을 뒤집어서 accessoryType
뒤에 맞춤 배경을 추가하는 것입니다.UIButton swizzling이 UITableViewCellAccessoryType의 문제를 일으킬 수 있습니다.
내가해야 할 일은 내가 뒤죽박죽하려는 UIButton
이 UITableViewCellAccessoryType
인지 아닌지 확인하는 것입니다. 그러나 나는 그런 일을하는 방법을 알지 못합니다.
다음은 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];
}
}
어떤 도움을 주시면 감사하겠습니다.
UIButton을 서브 클래스로 만들고, 그 클래스를 사용하여 새로운 클래스 만 쓸어 넘기시겠습니까? – lnafziger