Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To anyone struggling with this stuff like myself, modifying Karl's example, here is a simple experiment with the speech bubble drawing, moving the pointy part on its bottom length with CAMediaTimingFunction thrown in. This is basically what I wanted to do, when someone taps on a defined grid of items, the pointer moves into position to reflect tap selection.</p> <pre><code> UIBezierPath *spath = [UIBezierPath bezierPath]; [spath moveToPoint:CGPointZero]; [spath addLineToPoint:CGPointMake(320.0f, 0)]; [spath addLineToPoint:CGPointMake(320.0f, BLOCK_HEIGHT)]; // Pointy part [spath addLineToPoint:CGPointMake(20.0f + POINTER_HALF, BLOCK_HEIGHT)]; [spath addLineToPoint:CGPointMake(20.0f, BLOCK_HEIGHT + POINTER_HALF)]; [spath addLineToPoint:CGPointMake(20.0f - POINTER_HALF, BLOCK_HEIGHT)]; [spath addLineToPoint:CGPointMake(0, BLOCK_HEIGHT)]; [spath closePath]; UIBezierPath *spath2 = [UIBezierPath bezierPath]; [spath2 moveToPoint:CGPointZero]; [spath2 addLineToPoint:CGPointMake(320.0f, 0)]; [spath2 addLineToPoint:CGPointMake(320.0f, BLOCK_HEIGHT)]; // Pointy part [spath2 addLineToPoint:CGPointMake(300.0f + POINTER_HALF, BLOCK_HEIGHT)]; [spath2 addLineToPoint:CGPointMake(300.0f, BLOCK_HEIGHT + POINTER_HALF)]; [spath2 addLineToPoint:CGPointMake(300.0f - POINTER_HALF, BLOCK_HEIGHT)]; [spath2 addLineToPoint:CGPointMake(0, BLOCK_HEIGHT)]; [spath2 closePath]; CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.bounds = CGRectMake(0.f, 0.f, 320.0f, 76.0f); shapeLayer.position = CGPointMake(160.0, 200.0); shapeLayer.fillColor = [[UIColor redColor] CGColor]; shapeLayer.path = [[UIBezierPath bezierPathWithOvalInRect:shapeLayer.bounds] CGPath]; [self.layer addSublayer:shapeLayer]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"]; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; animation.fromValue = (__bridge id)(spath.CGPath); animation.toValue = (__bridge id)(spath2.CGPath); animation.repeatCount = NSIntegerMax; animation.duration = 2.0; animation.autoreverses = YES; [shapeLayer addAnimation:animation forKey:@"shapeAnimation"]; </code></pre>
    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.
    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