首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >iOS几款实用的工具类demo

iOS几款实用的工具类demo

作者头像
honey缘木鱼
发布2019-05-17 14:27:03
8510
发布2019-05-17 14:27:03
举报

一. 用UICollectionView左右滑动式布局

  1. 效果图:

UI设计

2.主要功能点:

  • 实现定时播放
  • 重复播放
  • 中间图片显示一定比例放大

3.主要功能代码:

- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect {
    
    NSArray *arr = [self getCopyOfAttributes:[super layoutAttributesForElementsInRect:rect]];
    //屏幕中线
    CGFloat centerX = self.collectionView.contentOffset.x + self.collectionView.bounds.size.width/2.0f;
    //刷新cell缩放
    for (UICollectionViewLayoutAttributes *attributes in arr) {
        CGFloat distance = fabs(attributes.center.x - centerX);
        //移动的距离和屏幕宽度的的比例
        CGFloat apartScale = distance/self.collectionView.bounds.size.width;
        //把卡片移动范围固定到 -π/4到 +π/4这一个范围内
        CGFloat scale = fabs(cos(apartScale * M_PI/4));
        //设置cell的缩放 按照余弦函数曲线 越居中越趋近于1
        attributes.transform = CGAffineTransformMakeScale(1.0, scale);
    }
    return arr;
}

4.demo下载地址

二.两个不同APP之间的聊天功能

1.主要功能点:

  • 不同APP之间
  • 实现单聊
  • 集成容云作为第三方选择

2.主要功能实现: 我们只需要申请一套 App Key / App Secrect,提供给两个 App 使用即可。上线前,您需要在开发者平台上填写这两个应用的包名(Bundle Identifier)即可。

 设置  [[RCIM sharedRCIM] setUserInfoDataSource:self];
- (void)getUserInfoWithUserId:(NSString *)userId completion:(void(^)(RCUserInfo* userInfo))completion
{}

3.demo下载地址

三.照片中文字识别功能

1.效果图

设计需求

2.主要功能点:

  • 百度智能云文字识别OCR
  • 裁剪,识别,分享,旋转,重置,校对等功能

3.关键代码:

  //识别图片
            [[AipOcrService shardService] detectWebImageFromImage:self.showImage
                                                      withOptions:nil
                                                   successHandler:_successHandler
                                                      failHandler:_failHandler];

4.demo下载地址

四.视频编辑

1.效果图

设计需求

2.主要功能点:

  • 本地视频选择播放
  • 裁剪,压缩,转换,弹幕等功能

3.关键代码:

//5.视频输出
    self.outputURL = [NSURL fileURLWithPath: self.outPutPath];
    AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:self.mixComposition presetName:self.presetName];
    
    exporter.outputURL = self.outputURL;
    exporter.videoComposition = self.videoComposition;
    exporter.outputFileType = [self transOutPutFileType:fileType];
    exporter.shouldOptimizeForNetworkUse = self.shouldOptimizeForNetworkUse;
    [exporter exportAsynchronouslyWithCompletionHandler:^{
        
        dispatch_async(dispatch_get_main_queue(), ^{
            if (exporter.status == AVAssetExportSessionStatusCompleted) {
                if (successBlock) {
                    successBlock(self.outputURL);
                }
            }else{
                NSLog(@"exporter %@",exporter.error);
                if (failureBlock) {
                    failureBlock(exporter.error);
                }
                
            }
        });
    }];
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.05.16 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一. 用UICollectionView左右滑动式布局
    • 二.两个不同APP之间的聊天功能
      • 三.照片中文字识别功能
        • 四.视频编辑
        相关产品与服务
        文字识别
        文字识别(Optical Character Recognition,OCR)基于腾讯优图实验室的深度学习技术,将图片上的文字内容,智能识别成为可编辑的文本。OCR 支持身份证、名片等卡证类和票据类的印刷体识别,也支持运单等手写体识别,支持提供定制化服务,可以有效地代替人工录入信息。
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档