MapKit缩放和CAKeyframeAnimation类使用!

- (void)setMapLocation:(CLLocationCoordinate2D)coordinate distance:(double)distance animated:(BOOL)animated{
    //[self saveLocationLatitude:coordinate.latitude Longitude:coordinate.longitude ];
    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(coordinate, distance, distance);
    MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];
    [self.mapView setRegion:adjustedRegion animated:animated];
}


如上可以缩放地图


CAKeyframeAnimation类使用

-(CAAnimation*)animation {
    
    
    CAKeyframeAnimation* animation;
    animation = [CAKeyframeAnimation animation];
    animation.path = path;
    CGPathRelease(path);
    animation.duration = 5;
    animation.repeatCount = 10000;
     animation.calculationMode = @"cubic";
    animation.calculationMode=kCAAnimationCubicPaced;
        return animation;
}

-(CAAnimation*)fadeInOutAnimation{
    CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
    animation.duration = 5;
    animation.repeatCount =10000;
    animation.toValue = [NSNumber numberWithFloat:.4];
    animation.autoreverses = YES;
    return animation;
}

-(void)startMoving{
    
    
   // [self.layer addAnimation:[self animation] forKey:@"position"];//圆周运动
    [imgView.layer addAnimation:[self animation] forKey:@"position"];
    [self.layer addAnimation:[self fadeInOutAnimation] forKey:@"opacity"];//阴影转动效果
    
   
    self.layer.needsDisplayOnBoundsChange = YES;
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    self.layer.position = CGPointMake(100, 100);
    self.layer.opacity = .4;
}

- (void) dealloc
{
    CGPathRelease(path);

    [super dealloc];
}


-(void)initPath{
    
    
    path = CGPathCreateMutable();

    CAShapeLayer *line =  [CAShapeLayer layer];
    
    
    line.lineWidth = 2.0f ;
    line.strokeColor = [UIColor orangeColor].CGColor;
    line.fillColor = [UIColor clearColor].CGColor;
    
    CGPathAddEllipseInRect(path, NULL, CGRectMake(100, 200, 200, 100));//椭圆路径,关键步骤。

    line.path = path;
    CGPathRelease(path);
    [self.layer addSublayer:line];
}

- (id)initWithFrame:(CGRect)aRect{
    self = [super initWithFrame:aRect];
    if(self != nil){
        [self initPath];

        imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 165, 82)];
        imgView.image = [UIImage imageNamed:@"weather_sun.png.png"];
        imgView.opaque = NO;
         [self addSubview:imgView];
        [self startMoving];
        [imgView release];
        return  self;
        
}

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值