1

I'm trying to implement the UILongPressGestureRecognizer method, but I'm not sure I have the code implemented correctly. I'm trying to change the colors implemented for a toolbar with a long press.

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 ;
    }
}

Here is the 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];
  • Welcome to SO. You need to explain, clearly, and in decent detail, what you want to do. "I'm trying to change the colors implemented for a toolbar with a long press" does not cut it. A long press gesture recognizer is continuous. It begins firing, and then calls with the changed state if the user moves his finger. What do you want to happen to the color of your toolbar while the finger is down? Describe it in terms of what the user sees in response to his gesture. (The fictional spec of what you're trying to do.) – Duncan C Nov 12 '15 at 02:30
  • What have you done? Does it work and get wrong result or what? – tuledev Nov 12 '15 at 03:33

0 Answers0