美文网首页想法简友广场
iOS.仿盲盒星球预览动画

iOS.仿盲盒星球预览动画

作者: 海边的遐想 | 来源:发表于2022-08-05 16:01 被阅读0次

    由于不能上传视频,姑且截几张图展示下样式


    image.png
    image.png

    这里的H5动画是放入本地的H5文件,动画就不赘述了,
    原生这边用的是WebView 加载动画,并实现交互
    1,webView 的初始化:


    image.png
    圈起来的地方是和前端约定好的交互方法:

    2,webView加载H5信息
    NSString *path = [[NSBundle mainBundle] pathForResource:@"h5/index" ofType:@"html"];
    NSString * urlstr= [NSString stringWithFormat:@"%@#/pages/goods/ask-answer/go-answer/index?order_sn=%@&token=%@",path,self.order_sn,[User getUserToken]];
    NSString * pathStr = [@"file://" stringByAppendingString:urlstr];
    NSURL *url = [NSURL URLWithString:pathStr];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
    如果有音乐的话,需要用AVPlayer播放相应的音乐

    pragma mark - 播放音乐

    -(void)playVideo {
    NSURL * url = [NSURL URLWithString:kVodCodeURL];
    AVPlayerItem * songItem = [[AVPlayerItem alloc]initWithURL:url];
    AVPlayer * player = [[AVPlayer alloc]initWithPlayerItem:songItem];
    self.player = player;
    [player play];
    }
    3,在代理方法中处理交互事件

    image.png

    相关文章

      网友评论

        本文标题:iOS.仿盲盒星球预览动画

        本文链接:https://www.haomeiwen.com/subject/mtppwrtx.html