我正在尝试实现UILongPressGestureRecognizer方法,但我不确定我是否正确实现了代码。我试图用长按更改为工具栏实现的颜色。
AwesomeFloatingToolbar.m
- (void) longPress:(UILongPressGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan) {
for (NSUInteger i = 0; i < [self.colors count] ; i++) {
if (i < 2) {
[self.colors objectAtIndex:i+1];
} else if (i == 2) {
[self.colors objectAtIndex:i+2];
} else if (i == 3) {
[self.colors objectAtIndex:0];
}
}
for (UILabel *thisLabel in self.labels) {
NSUInteger currentLabelIndex = [self.labels indexOfObject:thisLabel];
UIColor *colorForThisLabel = [self.colors objectAtIndex:currentLabelIndex];
thisLabel.backgroundColor = colorForThisLabel ;
}
}
这是self.colors
self.currentTitles = titles;
self.colors = [@[[UIColor colorWithRed:199/255.0 green:158/255.0 blue:203/255.0 alpha:1],
[UIColor colorWithRed:255/255.0 green:105/255.0 blue:97/255.0 alpha:1],
[UIColor colorWithRed:222/255.0 green:165/255.0 blue:164/255.0 alpha:1],
[UIColor colorWithRed:255/255.0 green:179/255.0 blue:71/255.0 alpha:1]]mutableCopy];