短视频系统源代码,iOS开发之实现点击图片放大3D效果

软件工具
0 1085
 
@interface FirmwareViewController ()
 
@property (strong, nonatomic)  UIImageView *tipImage;
 
@implementation FirmwareViewController
{
    UIView *background;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //点击图片放大
    _tipImage.userInteractionEnabled = YES;
    //添加点击手势
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
    [_tipImage addGestureRecognizer:tapGesture];
 
}
#pragma mark - 实现点击图片放大功能
//点击图片后的方法(即图片的放大全屏效果)
- (void) tapAction{
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    //创建一个黑色背景
    //初始化一个用来当做背景的View。
    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    background = bgView;
    [bgView setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:bgView];
    
    //创建显示图像的视图
    //初始化要显示的图片内容的imageView
    UIImageView *imgView = [[UIImageView alloc] init];
    
    //根据设备类型显示相应图片
    if ([BluetoothDataManage shareInstance].deviceType == 0) {
        //要显示的图片,即要放大的图片
        [imgView setImage:[UIImage imageNamed:@"updateFirmwareTip0"]];
    }else{
        [imgView setImage:[UIImage imageNamed:@"updateFirmwareTip"]];
    }
    [bgView addSubview:imgView];
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(ScreenHeight,ScreenWidth));
        make.centerX.equalTo(self.view.mas_centerX);
        make.centerY.equalTo(self.view.mas_centerY);
    }];
    imgView.transform=CGAffineTransformMakeRotation(M_PI_2);
    imgView.userInteractionEnabled = YES;
    //添加点击手势(即点击图片后退出全屏)
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeView)];
    [imgView addGestureRecognizer:tapGesture];
    
    [self shakeToShow:bgView];//放大过程中的动画
}
-(void)closeView{
    [background removeFromSuperview];
    [self.navigationController setNavigationBarHidden:NO animated:nil];
}
//放大过程中出现的缓慢动画
- (void) shakeToShow:(UIView*)aView{
    CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    animation.duration = 0.5;
    NSMutableArray *values = [NSMutableArray array];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 0.1)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
    animation.values = values;
    [aView.layer addAnimation:animation forKey:nil];
}


精选帖子
Android 可可影视 v3.3.6无广告纯净版 2914
Android QQ音乐 v11.3.7 定制版解锁免费听歌无广告版 3476
Android 草图大师SKP v1.5 解锁会员版 8812
Android OmoFun追漫神器 v4.2.1 无广告绿色版 5873
AdobeGenP Adobe全家桶系列激活工具 v3.5.0/3.4.14.1 绿色版 6452
Android 七猫免费听书 v1.4 解锁高级版 4886
超良心的抢票神器——Bypass1.16 4602
Android 玲珑加速器 v6.10.9.40 解锁无限时间 3260
Android 大师兄影视 v3.3.8 去广告会员版 2381
热门帖子
Hermes Agent 企业级实战:快速安装配置大模型,接入微信飞书企微钉钉全平台打通 70
国外网站出售虚拟商品,人人可做,只需简单上传,不用引流,最简单得网赚项目 57
AI电脑搬砖,教育风口一单500+,小白可做,提供接单资源 55
公众号小绿书贴图项目:一张图+标题+文案赚收益,听话照做一站式教学 55
最新AI量化交易5.0,小白轻松操作,绿色稳定!日入1000+ 52
快手风口项目,荧光计划托管,长期稳定,适合批量做 52
Agent Skills企业级实战:Skill工程定义+运行原理+实践指南,从零搭建企业AI能力 52
AI全自动挂机项目,电脑端轻松运行,稳定日入500+,零门槛上手 51
网红奶茶饮品配方:台式港式果茶奶盖杨枝甘露,完整资料包制作教程合集 46