扫一扫咨询方案
首页
登录/注册

{user.username}

ID: {user.id}

模板 SDK 文档

  • 云渲染

    • Demo下载
    • SDK
    • 开发指南
    • AI API 文档
    • 开发者 API 文档
    • 控制台指南
    • 快速入门
    • 产品简介
  • 模板SDK

    • 用户常见问题
    • Demo 下载
    • 开发指南
    • 服务端 SDK
    • iOS SDK
    • 安卓端 SDK
    • 产品简介
  • 剪辑SDK

    • Demo下载
    • SDK
    • 开发指南
    • 产品简介
  • 模板制作教程

    • 模板制作进阶教程
    • 测试模板素材案例下载
    • 常见模板制作案例
    • 模板制作教程
    • 模板制作工具下载
    • 入门指南
  • 剪辑制作教程

    • 剪辑特效导出教程
    • 剪辑特效测试素材
    • 剪辑特效制作工具下载
    • 入门指南
产品简介
安卓端 SDK
iOS SDK
服务端 SDK
开发指南
Demo 下载
用户常见问题
首页 > iOS SDK > 贴纸

贴纸

更新时间 : 2021-02-22 09:30:40

接口介绍

  1. 贴纸的管理使用 SXStickerManager ,在 SXTemplate 中获取。

  2. 可以添加多个贴纸,移除贴纸需要使用添加贴纸时获取到的 ID。

    //添加贴纸
    _stickerId = [_mTemplate.stickerManager addSticker:stickerPath];
    //移除贴纸
    [_mTemplate.stickerManager removeSticker:_stickerId];
  3. 每个贴纸可以进行旋转位移缩放,来达到期望的效果。

    //设置缩放
    [_mTemplate.stickerManager setStickerScale:_stickerId scaleX:scale.x * pinch.scale scaleY:scale.y * pinch.scale];
    //设置位移
    [_mTemplate.stickerManager setStickerPosition:_stickerId position:CGPointMake(_selectModelLabel.center.x / _playerScale, _selectModelLabel.center.y / _playerScale)];
    //设置旋转
    float rot = [_mTemplate.stickerManager getStickerRotation:_stickerId];
    rot += rotation.rotation / M_PI * 180;
    [_mTemplate.stickerManager setStickerRotate:_stickerId rotation:rot];
  4. 每个贴纸文件的解析可以参考标准模板,替换素材的 index 是这个素材在可替换素材中的排序。

    //替换贴纸中的index为0的可替换素材, path为替换上去的素材路径
    [_mTemplate.stickerManager replaceSource:_stickerId sourceIndex:0 withSource:path];
  5. 也可以针对指定素材设置旋转位移缩放。

    //设置缩放
    CGPoint scale = [_mTemplate.stickerManager getSourceScale:_stickerId sourceIndex:0];
    [_mTemplate.stickerManager setSourceScale:_stickerId sourceIndex:0 scaleX:scale.x * pinch.scale scaleY:scale.y * pinch.scale];
    //设置位移
    CGPoint translation = [pan translationInView:_modelView];
    CGPoint position = [_mTemplate.stickerManager getSourcePositon:_stickerId sourceIndex:0];
    [_mTemplate.stickerManager setSourcePosition:_stickerId sourceIndex:0 position:CGPointMake(position.x + translation.x / _playerScale, position.y + translation.y / _playerScale)];
    //设置旋转
    float rot = [_mTemplate.stickerManager getSourceRotation:_stickerId sourceIndex:0];
    rot += rotation.rotation / M_PI * 180;
    [_mTemplate.stickerManager setSourceRotate:_stickerId sourceIndex:0 rotation:rot];
首页 > iOS SDK > 贴纸
贴纸
更新时间 : 2021-02-22 09:30:40
  • 云渲染
    • Demo下载
    • SDK
    • 开发指南
    • AI API 文档
    • 开发者 API 文档
    • 控制台指南
    • 快速入门
    • 产品简介
  • 模板SDK
    • 用户常见问题
    • Demo 下载
    • 开发指南
    • 服务端 SDK
    • iOS SDK
    • 安卓端 SDK
    • 产品简介
  • 剪辑SDK
    • Demo下载
    • SDK
    • 开发指南
    • 产品简介
  • 模板制作教程
    • 模板制作进阶教程
    • 测试模板素材案例下载
    • 常见模板制作案例
    • 模板制作教程
    • 模板制作工具下载
    • 入门指南
  • 剪辑制作教程
    • 剪辑特效导出教程
    • 剪辑特效测试素材
    • 剪辑特效制作工具下载
    • 入门指南

接口介绍

  1. 贴纸的管理使用 SXStickerManager ,在 SXTemplate 中获取。

  2. 可以添加多个贴纸,移除贴纸需要使用添加贴纸时获取到的 ID。

    //添加贴纸
    _stickerId = [_mTemplate.stickerManager addSticker:stickerPath];
    //移除贴纸
    [_mTemplate.stickerManager removeSticker:_stickerId];
  3. 每个贴纸可以进行旋转位移缩放,来达到期望的效果。

    //设置缩放
    [_mTemplate.stickerManager setStickerScale:_stickerId scaleX:scale.x * pinch.scale scaleY:scale.y * pinch.scale];
    //设置位移
    [_mTemplate.stickerManager setStickerPosition:_stickerId position:CGPointMake(_selectModelLabel.center.x / _playerScale, _selectModelLabel.center.y / _playerScale)];
    //设置旋转
    float rot = [_mTemplate.stickerManager getStickerRotation:_stickerId];
    rot += rotation.rotation / M_PI * 180;
    [_mTemplate.stickerManager setStickerRotate:_stickerId rotation:rot];
  4. 每个贴纸文件的解析可以参考标准模板,替换素材的 index 是这个素材在可替换素材中的排序。

    //替换贴纸中的index为0的可替换素材, path为替换上去的素材路径
    [_mTemplate.stickerManager replaceSource:_stickerId sourceIndex:0 withSource:path];
  5. 也可以针对指定素材设置旋转位移缩放。

    //设置缩放
    CGPoint scale = [_mTemplate.stickerManager getSourceScale:_stickerId sourceIndex:0];
    [_mTemplate.stickerManager setSourceScale:_stickerId sourceIndex:0 scaleX:scale.x * pinch.scale scaleY:scale.y * pinch.scale];
    //设置位移
    CGPoint translation = [pan translationInView:_modelView];
    CGPoint position = [_mTemplate.stickerManager getSourcePositon:_stickerId sourceIndex:0];
    [_mTemplate.stickerManager setSourcePosition:_stickerId sourceIndex:0 position:CGPointMake(position.x + translation.x / _playerScale, position.y + translation.y / _playerScale)];
    //设置旋转
    float rot = [_mTemplate.stickerManager getSourceRotation:_stickerId sourceIndex:0];
    rot += rotation.rotation / M_PI * 180;
    [_mTemplate.stickerManager setSourceRotate:_stickerId sourceIndex:0 rotation:rot];