無標(biāo)題文章

//序列幀動(dòng)畫要播放的圖片數(shù)組

// ???imageView.animationImages

//動(dòng)畫時(shí)長(zhǎng)

// ???imageView.animationDuration

//動(dòng)畫重復(fù)次數(shù)

// ???imageView困鸥。animationRepeatCount

//開始動(dòng)畫

// ???[imageView startAnimating]

//結(jié)束動(dòng)畫

// ???[imageView stopAnimating]

//是否執(zhí)行動(dòng)畫

// ???[imageView isAnimating]

//序列幀動(dòng)畫要播放的圖片數(shù)組

// ???imageView.animationImages

//動(dòng)畫時(shí)長(zhǎng)

// ???imageView.animationDuration

//動(dòng)畫重復(fù)次數(shù)

// ???imageView退腥。animationRepeatCount

//開始動(dòng)畫

// ???[imageView startAnimating]

//結(jié)束動(dòng)畫

// ???[imageView stopAnimating]

//是否執(zhí)行動(dòng)畫

// ???[imageView isAnimating]

例:湯姆貓動(dòng)畫(1)

//

// ?ViewController.m

//湯姆貓

//

// ?Created by lanou on 16/7/12.

//?Copyright ? 2016年lanou. All rights reserved.

//

#import"ViewController.h"

@interfaceViewController()

@property(weak,nonatomic)IBOutletUIImageView*tomcatview;

@end

@implementationViewController

- (void)viewDidLoad {

[superviewDidLoad];

}

- (IBAction)eatBirdAction:(UIButton*)sender {

//創(chuàng)建可變數(shù)組

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<40;i++) {

//根據(jù)i來加載圖片杠览,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"eat_%02ld.jpg",i];

//根據(jù)格式化的圖片名加載圖片

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

//設(shè)置動(dòng)畫圖片數(shù)組

self.tomcatview.animationImages= images;

//設(shè)置動(dòng)畫時(shí)長(zhǎng)

self.tomcatview.animationDuration=40*0.075;

//設(shè)置動(dòng)畫重復(fù)次數(shù)

self.tomcatview.animationRepeatCount=1;

//開始動(dòng)畫

[self.tomcatviewstartAnimating];

}

(IBAction)drink:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<81;i++) {

//根據(jù)i來加載圖片乐纸,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"drink_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=81*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

- (IBAction)cymbal:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<13;i++) {

//根據(jù)i來加載圖片伟葫,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"cymbal_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=13*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

- (IBAction)fart:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<28;i++) {

//根據(jù)i來加載圖片,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"fart_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=28*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

- (IBAction)pie:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<24;i++) {

//根據(jù)i來加載圖片隙姿,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"pie_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=24*0.075;

self.tomcatview.animationRepeatCount=1;

self.tomcatviewstartAnimating];

}

- (IBAction)scratch:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<56;i++) {

//根據(jù)i來加載圖片户敬,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"scratch_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=56*0.075;

self.tomcatview.animationRepeatCount=1;

self.tomcatviewstartAnimating];

}

- (IBAction)footleft:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<30;i++) {

//根據(jù)i來加載圖片,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"footleft_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=30*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

- (IBAction)footright:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<30;i++) {

//根據(jù)i來加載圖片想帅,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"footright_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=30*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

- (IBAction)stomach:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<34;i++) {

//根據(jù)i來加載圖片场靴,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"stomach_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=34*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

- (IBAction)angry:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<26;i++) {

//根據(jù)i來加載圖片,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"angry_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=26*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

- (IBAction)knockout:(UIButton*)sender {

NSMutableArray*images = [NSMutableArrayarray];

for(NSIntegeri =0;i<81;i++) {

//根據(jù)i來加載圖片,然后添加到可變數(shù)組image里面

NSString*imageName = [NSStringstringWithFormat:@"knockout_%02ld.jpg",i];

UIImage*image = [UIImageimageNamed:imageName];

[imagesaddObject:image];

}

self.tomcatview.animationImages= images;

self.tomcatview.animationDuration=81*0.075;

self.tomcatview.animationRepeatCount=1;

[self.tomcatviewstartAnimating];

}

-(void)didReceiveMemoryWarning {

[superdidReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

例:湯姆貓動(dòng)畫(2)

//

//? ViewController.m

//? 湯姆貓

//

//? Created by lanou on 16/7/12.

//? Copyright ?0?8 2016年 lanou. All rights reserved.

//

#import "ViewController.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *tomcatview;

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

}

- (IBAction)eatBirdAction:(UIButton *)sender {

[self tomCatAnimationWithName:@"eat" withCount:40];(調(diào)用編好的代碼組旨剥,方便快捷)

}

- (IBAction)drink:(UIButton *)sender {

[self tomCatAnimationWithName:@"drink" withCount:81];(調(diào)用編好的代碼組咧欣,方便快捷)

}

- (IBAction)cymbal:(UIButton *)sender {

[self tomCatAnimationWithName:@"cymbal" withCount:13];(調(diào)用編好的代碼組,方便快捷)

}

- (IBAction)fart:(UIButton *)sender {

[self tomCatAnimationWithName:@"fart" withCount:28];(調(diào)用編好的代碼組泞边,方便快捷)

}

- (IBAction)pie:(UIButton *)sender {

[self tomCatAnimationWithName:@"pie" withCount:24];(調(diào)用編好的代碼組该押,方便快捷)

}

- (IBAction)scratch:(UIButton *)sender {

[self tomCatAnimationWithName:@"scratch" withCount:56];(調(diào)用編好的代碼組,方便快捷)

}

- (IBAction)footleft:(UIButton *)sender {

[self tomCatAnimationWithName:@"footleft" withCount:30];(調(diào)用編好的代碼組阵谚,方便快捷)

}

- (IBAction)footright:(UIButton *)sender {

[self tomCatAnimationWithName:@"footright" withCount:30];(調(diào)用編好的代碼組蚕礼,方便快捷)

}

- (IBAction)stomach:(UIButton *)sender {

[self tomCatAnimationWithName:@"stomach" withCount:34];(調(diào)用編好的代碼組,方便快捷)

}

- (IBAction)angry:(UIButton *)sender {

[self tomCatAnimationWithName:@"angry" withCount:26];(調(diào)用編好的代碼組梢什,方便快捷)

}

- (IBAction)knockout:(UIButton *)sender {

[self tomCatAnimationWithName:@"knockout" withCount:81];(調(diào)用編好的代碼組奠蹬,方便快捷)

}

//代碼組

-(void)tomCatAnimationWithName:(NSString*)name withCount:(NSInteger)count

{

if([self.tomcatview isAnimating]){

return;

}

//創(chuàng)建可變數(shù)組

NSMutableArray *images = [NSMutableArray array];

for (NSInteger i = 0;i< count;i++) {

//? ? ? ? 根據(jù)i來加載圖片,然后添加到可變數(shù)組image里面

NSString *imageName = [NSString stringWithFormat:@"%@_%02ld.jpg",name,i];

//? ? ? 根據(jù)格式化的圖片名加載圖片

UIImage *image = [UIImage imageNamed:imageName];

[images addObject:image];

}

//? ? 設(shè)置動(dòng)畫圖片數(shù)組

self.tomcatview.animationImages = images;

//? 設(shè)置動(dòng)畫時(shí)長(zhǎng)

self.tomcatview.animationDuration = count*0.075;

//? ? 設(shè)置動(dòng)畫重復(fù)次數(shù)

self.tomcatview.animationRepeatCount = 1;

//? ? 開始動(dòng)畫

[self.tomcatview startAnimating];

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

//Dspose of any resources that can be recreated.

}

@end




//ViewController.m

//訪問系統(tǒng)相冊(cè)

//

//Created by lanou on 16/7/12.

//Copyright?0?8 2016年lanou.All rights reserved.

//

#import"ViewController.h"

//遵守協(xié)議

@interface ViewController()

@property(nonatomic,strong)UIButton*userBtn;

@end

@implementation? ViewController

-(void)viewDidLoad{

[superviewDidLoad];

//所有能看到的UI控件創(chuàng)建初始化方式都可以采用alloc initWithFrame

self.userBtn=[[UIButtonalloc]initWithFrame:CGRectMake(20,60,80,80)];

//設(shè)置顏色

self.userBtn.backgroundColor=[UIColorredColor];

//設(shè)置圓形半徑

self.userBtn.layer.cornerRadius=40;

self.userBtn.layer.masksToBounds=YES;

//添加點(diǎn)擊事件:去訪問系統(tǒng)相冊(cè)

[self.userBtnaddTarget:selfaction:@selector(setUserImage)forControlEvents:(UIControlEventTouchUpInside)];

//添加按鈕到屏幕上來

[self.viewaddSubview:self.userBtn];

}

//訪問系統(tǒng)相冊(cè)

-(void)setUserImage

{

//創(chuàng)建系統(tǒng)相冊(cè)

UIImagePickerController*imagePicker=[[UIImagePickerControlleralloc]init];

//設(shè)置代理嗡午,到@interface后面遵守協(xié)議

imagePicker.delegate=self;

//彈出系統(tǒng)相冊(cè)

[selfpresentViewController:imagePickeranimated:YEScompletion:nil];

}

//這個(gè)方法是協(xié)議UIImagePickerControllerDelegate里面的囤躁,選擇圖片結(jié)束的時(shí)候就會(huì)自動(dòng)調(diào)用

-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(nullableNSDictionary

*)editingInfo

{

//設(shè)置頭像

[self.userBtnsetBackgroundImage:imageforState:(UIControlStateNormal)];

//將系統(tǒng)相冊(cè)消失

[pickerdismissViewControllerAnimated:YEScompletion:nil];

}

-(void)didReceiveMemoryWarning{

[superdidReceiveMemoryWarning];

//Dispose of any resources that can be recreated.

}

@end

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市荔睹,隨后出現(xiàn)的幾起案子狸演,更是在濱河造成了極大的恐慌,老刑警劉巖僻他,帶你破解...
    沈念sama閱讀 221,198評(píng)論 6 514
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件宵距,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡吨拗,警方通過查閱死者的電腦和手機(jī)满哪,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,334評(píng)論 3 398
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來劝篷,“玉大人哨鸭,你說我怎么就攤上這事〗考耍” “怎么了像鸡?”我有些...
    開封第一講書人閱讀 167,643評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)哈恰。 經(jīng)常有香客問我坟桅,道長(zhǎng),這世上最難降的妖魔是什么蕊蝗? 我笑而不...
    開封第一講書人閱讀 59,495評(píng)論 1 296
  • 正文 為了忘掉前任仅乓,我火速辦了婚禮,結(jié)果婚禮上蓬戚,老公的妹妹穿的比我還像新娘夸楣。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,502評(píng)論 6 397
  • 文/花漫 我一把揭開白布豫喧。 她就那樣靜靜地躺著石洗,像睡著了一般。 火紅的嫁衣襯著肌膚如雪紧显。 梳的紋絲不亂的頭發(fā)上讲衫,一...
    開封第一講書人閱讀 52,156評(píng)論 1 308
  • 那天,我揣著相機(jī)與錄音孵班,去河邊找鬼涉兽。 笑死,一個(gè)胖子當(dāng)著我的面吹牛篙程,可吹牛的內(nèi)容都是我干的枷畏。 我是一名探鬼主播,決...
    沈念sama閱讀 40,743評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼虱饿,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼拥诡!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起氮发,我...
    開封第一講書人閱讀 39,659評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤渴肉,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后爽冕,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體仇祭,經(jīng)...
    沈念sama閱讀 46,200評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,282評(píng)論 3 340
  • 正文 我和宋清朗相戀三年扇售,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了前塔。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片嚣艇。...
    茶點(diǎn)故事閱讀 40,424評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡承冰,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出食零,到底是詐尸還是另有隱情困乒,我是刑警寧澤,帶...
    沈念sama閱讀 36,107評(píng)論 5 349
  • 正文 年R本政府宣布贰谣,位于F島的核電站娜搂,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏吱抚。R本人自食惡果不足惜百宇,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,789評(píng)論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望秘豹。 院中可真熱鬧携御,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,264評(píng)論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至誓军,卻和暖如春袱讹,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背昵时。 一陣腳步聲響...
    開封第一講書人閱讀 33,390評(píng)論 1 271
  • 我被黑心中介騙來泰國(guó)打工捷雕, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人债查。 一個(gè)月前我還...
    沈念sama閱讀 48,798評(píng)論 3 376
  • 正文 我出身青樓非区,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親盹廷。 傳聞我的和親對(duì)象是個(gè)殘疾皇子征绸,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,435評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容