0

Part of my iPad app allows users to draw paths to connect different parts of the screen. They all have the same color (white) and line width. Each path is represented as a UIBezierPath. Besides their locations, they look identical. Since users are only editing one path at a time, I want to make it so that they can visually see which path they are editing.

Is there a way to animate the path, so that the user has a visual queue about which path they are editing? I'm thinking that maybe the current path could glow or have moving dotted lines. I don't want to change the base color, since I use many colors in the other parts of application (pretty much all major colors except white).

4

1 に答える 1

0

I haven't done this in an animated way, but I make my currently drawing paths have dashed lines, and then solid once the drawing ends. I subclassed NSBezierPath, and added a selected property. The setSelected method looks like this:

-(void)setSelected:(BOOL) yes_no {
    selected = yes_no;
   if (yes_no == YES) {
        CGFloat dashArray[2];
        dashArray[0] = 5;
        dashArray[1] = 2;
        [self setLineDash:dashArray count:2 phase:0];
       self.pathColor = [self.unselectedColor highlightWithLevel:.5];
   } else {
       [self setLineDash:nil count:2 phase:0];
        self.pathColor = self.unselectedColor;
   }
}

I set the property to YES in the mouseDragged: method, and then to NO in mouseUP:

于 2012-05-03T20:17:30.790 に答える