1 改变状态栏(手机屏幕最上面的状态栏,电池时间那个栏目)
/** modify status bar */ -(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; }
2 增加蒙板的写法
/** 大图*/ - (IBAction)bigImage { //增加蒙板 //将图片移动到视图的顶层 //计算图片的目标位置,动画显示 UIButton *button = [[UIButton alloc]initWithFrame:self.view.bounds]; button.alpha = 0.5f; button.backgroundColor = [UIColor blackColor]; [self.view addSubview:button]; //将视图拿到顶层 [self.view bringSubviewToFront:self.iconView]; //先计算目标位置 CGFloat viewW = self.view.bounds.size.width; CGFloat imageW = viewW; CGFloat imageH = imageW; CGFloat imageY = (self.view.bounds.size.height-imageH)*0.5; // [UIView beginAnimations:nil context:nil]; // [UIView setAnimationDuration:2.0f]; // self.iconView.frame = CGRectMake(0, imageY, imageW, imageH); // [UIView commitAnimations]; [UIView animateWithDuration:1.0f animations:^{ self.iconView.frame = CGRectMake(0, imageY, imageW, imageH); } completion:^(BOOL finished) { // }]; }
3 拦截首尾式动画结束的方法
-(void)smallImage{ //动画变小 // [UIView animateWithDuration:1.0f animations:^{ // self.iconView.frame = CGRectMake(85, 135, 150, 150); // // } completion:^(BOOL finished) { // [self.cover removeFromSuperview]; // }]; //拦截首尾式动画结束的方法 [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0f]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(removeCover)]; self.iconView.frame = CGRectMake(85, 135, 150, 150); [UIView commitAnimations]; //隐藏遮罩 } -(void)removeCover{ [self.cover removeFromSuperview]; }
原文:http://www.cnblogs.com/lihaozhou/p/4360931.html