Note that there are some explanatory texts on larger screens.

plurals
  1. POCGAffineTransformScale not scaling a gesture area
    primarykey
    data
    text
    <p>I have a 3x3 grid of UIViews with UIGestureRecognizers added to them, arranged like so:</p> <p><img src="https://i.stack.imgur.com/rVrdR.png" alt="State1"></p> <p>The way it works is that tapping on a square enlarges it 2x using CGAffineTransformScale and overlays that over the other squares. The problem is that the touch area stays the same size as the 1.0 scale for some reason. </p> <p>I add the squares using</p> <pre><code>CGRect squareFrame = CGRectMake(1 + squareSpacing + ((squareDimension + squareSpacing) * i), topMargin, squareDimension, squareDimension); SquareView *square = [[SquareView alloc] initWithFrame:squareFrame]; [square setPosition:i]; square.layer.zPosition = 0; [self.view addSubview:square]; [squaresArray addObject:square]; </code></pre> <p>The Squares have gesture recognizers added in their init:</p> <pre><code>fingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)]; [self addGestureRecognizer:fingerTap]; </code></pre> <p>The tapped function does the following:</p> <pre><code>[UIView animateWithDuration:1.0 delay:0.0 usingSpringWithDamping:0.8 initialSpringVelocity:10.0 options:UIViewAnimationOptionCurveEaseOut animations:^{ CGAffineTransform transform = self.transform; self.transform = CGAffineTransformScale(transform, 2.0, 2.0); } completion:nil]; </code></pre> <p><img src="https://i.stack.imgur.com/5OrDb.png" alt="State2"></p> <p>I outlined the touch area in red. I have tried playing with the zPosition but I don't know what to do to make it work, I am stuck. I want to be able to tap the enlarged square <em>anywhere</em> for it to close, but I am limited to the red area.</p> <p>Thanks in advance.</p> <p><strong>EDIT</strong>: Sorry that the pictures are so large. Code added.</p> <ul> <li>Steven</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload