お遊び：何かをくるくる回してみた

![arrowvideo.gif](https://qiita-image-store.s3.amazonaws.com/0/7946/5b3e4edf-09b4-e599-8faa-b77e044ec72e.gif "arrowvideo.gif")

いろいろすっ飛ばしてソースコードだけ。

```objective-c:View.m
- (void)drawRect:(CGRect)rect
{
    
    //// General Declarations
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    //// Color Declarations
    UIColor* color3 = [UIColor colorWithRed: 1 green: 0.41 blue: 0.114 alpha: 1];
    
    //// Gradient Declarations
    NSArray* gradientColors = [NSArray arrayWithObjects:
                               (id)color3.CGColor,
                               (id)[UIColor colorWithRed: 1 green: 0.705 blue: 0.557 alpha: 1].CGColor,
                               (id)[UIColor whiteColor].CGColor, nil];
    CGFloat gradientLocations[] = {0, 0.61, 1};
    CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)gradientColors, gradientLocations);
    
    //// Bezier Drawing
    UIBezierPath* bezierPath = [UIBezierPath bezierPath];
    [bezierPath moveToPoint: CGPointMake(24.7, 24.7)];
    [bezierPath addCurveToPoint: CGPointMake(24.7, 35.3) controlPoint1: CGPointMake(21.77, 27.63) controlPoint2: CGPointMake(21.77, 32.37)];
    [bezierPath addCurveToPoint: CGPointMake(35.3, 35.3) controlPoint1: CGPointMake(27.63, 38.23) controlPoint2: CGPointMake(32.37, 38.23)];
    [bezierPath addCurveToPoint: CGPointMake(35.3, 24.7) controlPoint1: CGPointMake(38.23, 32.37) controlPoint2: CGPointMake(38.23, 27.63)];
    [bezierPath addCurveToPoint: CGPointMake(24.7, 24.7) controlPoint1: CGPointMake(32.37, 21.77) controlPoint2: CGPointMake(27.63, 21.77)];
    [bezierPath closePath];
    [bezierPath moveToPoint: CGPointMake(50, 30)];
    [bezierPath addCurveToPoint: CGPointMake(30, 50) controlPoint1: CGPointMake(50, 41.05) controlPoint2: CGPointMake(41.05, 50)];
    [bezierPath addCurveToPoint: CGPointMake(10, 30) controlPoint1: CGPointMake(18.95, 50) controlPoint2: CGPointMake(10, 41.05)];
    [bezierPath addCurveToPoint: CGPointMake(30, 0) controlPoint1: CGPointMake(10, 18.95) controlPoint2: CGPointMake(27.19, 0)];
    [bezierPath addCurveToPoint: CGPointMake(50, 30) controlPoint1: CGPointMake(32.81, 0) controlPoint2: CGPointMake(50, 18.95)];
    [bezierPath closePath];
    CGAffineTransform trans = CGAffineTransformMakeScale(self.bounds.size.width/60,
                                                         self.bounds.size.height/60);
    [bezierPath applyTransform:trans];
    CGContextSaveGState(context);
    [bezierPath addClip];
    CGContextDrawLinearGradient(context, gradient,
                                CGPointMake(self.bounds.size.width/2, 0),
                                CGPointMake(self.bounds.size.width/2, self.bounds.size.height),
                                0);
    CGContextRestoreGState(context);
    [[UIColor orangeColor] setStroke];

    bezierPath.lineWidth = 1;
    [bezierPath stroke];
    
    
    //// Cleanup
    CGGradientRelease(gradient);
    CGColorSpaceRelease(colorSpace);


}

```

```objective-c:ViewController.m
-(void)viewDidAppear:(BOOL)animated
{
    // y軸に対して回転．（z軸を指定するとUIViewのアニメーションのように回転）
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    
    // アニメーションのオプションを設定
    animation.duration = 5; // アニメーション速度
    animation.repeatCount = HUGE_VALF; // 繰り返し回数
    
    // 回転角度を設定
    animation.fromValue = [NSNumber numberWithFloat:0.0]; // 開始時の角度
    animation.toValue = [NSNumber numberWithFloat:2 * M_PI]; // 終了時の角度
    
    // アニメーションを追加
    [self.arrowView.layer addAnimation:animation forKey:@"rotate-layer"];
}
```