国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

停靠模式+GIF

2019-11-14 19:16:57
字體:
來源:轉載
供稿:網友

UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(0,20,200,200)];

redView.backgroundColor=[UIColor redColor];

//允許子視圖放大或縮小 默認autoresizeSubviews的就為YES

redView.autoresizeSubview=YES;

redView.tag=100;

[self.window addSubview:redView];

 

UIView *yellowView=[[UIView alloc]initWithFrame:CGRectMake(0,0,100,100)];

//按照可縮放的高度進行放大或縮小

yellowView.autoresizingMask=UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexbleWidth;

yellowView.backgroundColor=[UIColor yellowColor];

[redView addSubview:yellowView];

UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];

[btn setTitle:@"放大" forState:UIControlStateNormal];

btn.frame=CGRectMake(100,300,100,30);

[self.window addSubview:btn];

[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];

 

 

-(void)btnClick:(UIButton *)bt

{
UIView *redView=[self.window viewWithTag:100];

redView.frame=CGRectMake(redView.frame.origin.x,redView.frame.origin.y,redView.frame.size.width+10,redView.frame.size.height+10);

}

//GIF 用第三方庫

(1)

//獲得圖片路徑

NSString *imgPath=[[NSBundle mainBundle]pathForResource:@"FlagZombie" ofType:@"gif"];

//通過指定路徑下的文件初始化NSData

NSData *data=[[NSData alloc]initWithContentOfFile:imgPath];

UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(100,100,50,50)];

imgView.image=[UIImage animatedImageWithAnimatedGIFData:data];

[self.window addSubview:imgView];

(2)

NSURL *url=[[NSBundle mainBundle]URLForResource:@"FlagZombie" withExtension:@"gif"];

UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(200,100,80,80)];

//通過類別中的方法animatedImageWithAnimatedGIFURL實現Gif的圖片的播放

imgView.imge=[UIImage animatedImageWithAnimatedGIFURL:url];

imgView.tag=100;

[self.window addSubview:imgView];

//通過定時器實現每一段時間調用move方法

[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(move) userInfo:nil repeats:YES];

-(void)move{
UIImageView *imgView=(UIImageView *)[self.window viewWithTag:100];

//當圖片的x坐標大于80,沒調用move都使圖片向左側偏移5個單位

if(imgView.frame.origin.x>80){
imgView.frame=CGRectMake(imgView.frame.origin.x-5,imgView.frame.origin.y,imgView.frame.size.width,imgView.frame.size.height);

     }

}

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永平县| 宜宾市| 巴里| 内丘县| 疏勒县| 上饶县| 温泉县| 蕉岭县| 武邑县| 江源县| 新郑市| 晋江市| 广南县| 平阴县| 城市| 林周县| 巩留县| 资溪县| 溆浦县| 建阳市| 昌江| 乐至县| 林口县| 揭阳市| 峨山| 洪洞县| 郸城县| 德州市| 宾川县| 巴中市| 建瓯市| 保定市| 五台县| 板桥市| 海淀区| 额尔古纳市| 湘乡市| 东方市| 龙门县| 武隆县| 资兴市|