标签:events comm img 图标 png add let tar nis
/** 大图 */ - (IBAction)bigImg { //1.添加按钮遮罩层 UIButton *cover=[[UIButton alloc] init]; cover.frame=self.view.bounds; cover.backgroundColor=[UIColor blackColor]; cover.alpha=0.0; [cover addTarget:self action:@selector(smallImg) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:cover]; self.cover=cover; //2.更新阴影和头像的位置 [self.view bringSubviewToFront:self.iconImage]; //[UIView beginAnimations:nil context:nil]; //执行动画遮罩层慢慢显示 [UIView animateWithDuration:1.0 animations:^{ cover.alpha=0.7;//设置透明度 CGFloat iconW=self.view.frame.size.width; CGFloat iconH=iconW; CGFloat iconX=0; CGFloat iconY=(self.view.frame.size.height-iconH)*0.5; //CGRect myframe=self.iconImage.frame; self.oldRect=self.iconImage.frame; self.iconImage.frame=CGRectMake(iconX, iconY, iconW, iconH); }]; //[UIView commitAnimations]; } /** 小图 */ - (IBAction)smallImg{ [UIView animateWithDuration:1.0 animations:^{ //1.需要执行动画的代码 //1.1缩回图标 self.iconImage.frame=self.oldRect; self.cover.alpha=0.0; } completion:^(BOOL finished) { //2动画完成后执行的代码 //2.1清除阴影 [self.cover removeFromSuperview]; self.cover=nil; }]; }
标签:events comm img 图标 png add let tar nis
原文地址:http://www.cnblogs.com/zqrios/p/7415519.html