CAKeyframeAnimation

import "shipAction.h"

import "UIImageView+WebCache.h"

@interface shipAction ()

{

UIImageView *imageVV;
UIImageView *imageV;
UIView *myView;
UIImageView *imageVVV;
NSTimer *timer;

UIView *shipView;

}

@end

@implementation shipAction

-(instancetype)initWithName:(NSString *)name and:(NSString *)icon{

self = [super init];
if (self) {
    
  
    
    //船
    
    imageV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yacht_hull.png"]];
    
    imageV.userInteractionEnabled = YES;

    
    imageV.contentMode = UIViewContentModeScaleAspectFit;
    
    
    imageV.frame = CGRectMake(50,30,kSCREEN_WIDTH/1.5,kSCREEN_WIDTH);
    
    
    imageV.contentMode = UIViewContentModeScaleAspectFit;
    
    
    imageV.userInteractionEnabled = YES;
    
    /*
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.layer.masksToBounds = YES;
    btn.layer.borderColor = backColor.CGColor;
    btn.layer.borderWidth = 1;
    [btn sd_setImageWithURL:[NSURL URLWithString:icon] forState:UIControlStateNormal];
    btn.frame = CGRectMake(kSCREEN_WIDTH*0.4,120, 40, 40);
    btn.layer.cornerRadius = 20.0;
    [imageV addSubview:btn];
    [btn addTarget:self action:@selector(Upmessage) forControlEvents:UIControlEventTouchUpInside];
    */
    /*
    UILabel *label = [[UILabel alloc]init];
    label.text = [NSString stringWithFormat:@"%@贈(zèng)送了豪華游輪",name];
    label.textColor = backColor;
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:14];
    label.frame = CGRectMake(0,160,kSCREEN_WIDTH,20);
    [imageV addSubview:label];
    */
   // [imageV addSubview:btn];

    //海洋
    imageVV = [[UIImageView alloc]initWithFrame:CGRectMake(-kSCREEN_WIDTH,0,kSCREEN_WIDTH*2,kSCREEN_HEIGHT*0.6)];
    imageVV.contentMode = UIViewContentModeScaleAspectFit;
    imageVV.image = [UIImage imageNamed:@"yacht_water_one.png"];
    
    imageVVV = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,kSCREEN_WIDTH*2,kSCREEN_HEIGHT*0.6)];
    imageVVV.contentMode = UIViewContentModeScaleAspectFit;
    imageVVV.image = [UIImage imageNamed:@"yacht_water_one.png"];
    
    myView = [[UIView alloc]initWithFrame:CGRectMake(0,kSCREEN_HEIGHT*0.4,kSCREEN_WIDTH,kSCREEN_HEIGHT*0.6)];
    
    myView.userInteractionEnabled = YES;
    
    imageVV.userInteractionEnabled = YES;
    
    imageVVV.userInteractionEnabled = YES;
    

    
    [myView addSubview:imageVVV];
    
    [myView addSubview:imageVV];
    
    [myView addSubview:imageV];
    
    [self addSubview:myView];
    
    [self timeII];
    
    [self donghua];
    
    
}


return self;

}
-(void)donghua{

CGFloat yy =80;


CGFloat w = kSCREEN_WIDTH/1.5;

CGFloat ww = kSCREEN_WIDTH;


CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

animation.duration = 9.0;

NSValue *value14 = [NSValue valueWithCGRect:CGRectMake(50,0,ww,ww)];

NSValue *value15 = [NSValue valueWithCGRect:CGRectMake(50,10,ww,ww)];


NSValue *value1 = [NSValue valueWithCGRect:CGRectMake(50,30,w,w)];

NSValue *value2 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*0.3,yy,ww,ww)];

// NSValue value5 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH0.3,yy,w, w)];

NSValue *value6 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*0.5,yy+30,w, w)];

NSValue *value12 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*0.5,yy+10,w, w)];

NSValue *value7 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*0.5,yy,w, w)];

NSValue *value9 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*0.8,yy,w, w)];

NSValue *value10 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*1.2,yy,w, w)];

NSValue *value13 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*1.5,yy,w, w)];

NSValue *value11 = [NSValue valueWithCGRect:CGRectMake(kSCREEN_WIDTH*2,yy,w, w)];

animation.values = @[value14,value15,value1,value2,value6,value12,value7,value9,value10,value11,value13];

animation.removedOnCompletion = NO;

animation.fillMode = kCAFillModeForwards;

[imageV.layer addAnimation:animation forKey:nil];

}

-(void)timeII{
[UIView animateWithDuration:10.0 animations:^{
imageVVV.frame = CGRectMake(-kSCREEN_WIDTH,0,kSCREEN_WIDTH2,kSCREEN_HEIGHT0.6);
imageVV.frame = CGRectMake(0,0,kSCREEN_WIDTH2,kSCREEN_HEIGHT0.6);

}];

}

-(void)Upmessage{

[[NSNotificationCenter defaultCenter]postNotificationName:@"ship" object:nil];

}

@end

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • CAKeyframeAnimation:關(guān)鍵幀動(dòng)畫 是通過某一屬性按照一串的數(shù)值進(jìn)行動(dòng)畫,就好像制作動(dòng)畫的時(shí)候一幀...
    Evan葉少閱讀 908評(píng)論 0 1
  • 在iOS中隨處都可以看到絢麗的動(dòng)畫效果,實(shí)現(xiàn)這些動(dòng)畫的過程并不復(fù)雜,今天將帶大家一窺ios動(dòng)畫全貌。在這里你可以看...
    每天刷兩次牙閱讀 8,697評(píng)論 6 30
  • 在iOS中隨處都可以看到絢麗的動(dòng)畫效果,實(shí)現(xiàn)這些動(dòng)畫的過程并不復(fù)雜,今天將帶大家一窺iOS動(dòng)畫全貌。在這里你可以看...
    F麥子閱讀 5,271評(píng)論 5 13
  • iOS開發(fā)系列--網(wǎng)絡(luò)開發(fā) 概覽 大部分應(yīng)用程序都或多或少會(huì)牽扯到網(wǎng)絡(luò)開發(fā),例如說新浪微博、微信等,這些應(yīng)用本身可...
    lichengjin閱讀 4,046評(píng)論 2 7
  • 這種不需要經(jīng)過兩性生殖細(xì)胞的結(jié)合 由母體直接產(chǎn)生新個(gè)體的生殖方式叫無性生殖 這種方式繁殖的后代 與親代的遺傳信息一...
    簡(jiǎn)書簡(jiǎn)述簡(jiǎn)單讀閱讀 665評(píng)論 0 0

友情鏈接更多精彩內(nèi)容