IOS 10 新特性以及介绍

<pre>前言:iOS 10 发布有一段时间了,本次主要看看iOS 10 有哪些新的特性</pre>

  • Widget 可以在搜索界面、主屏可以看到
  • Message 可以添加自定义内容(类型微信表情),Message中添加自定义程序内容
  • SiriSDK开放 可以通过语音调取有特定功能的App内容
  • Notifications添加新的样式,可以实现预览

1.Today Widget 变更

主要是添加显示模式:
<pre>
<code>
@property (nonatomic, assign) NCWidgetDisplayMode widgetLargestAvailableDisplayMode NS_AVAILABLE_IOS(10_0);</code>
<code>
@property (nonatomic, assign, readonly) NCWidgetDisplayMode widgetActiveDisplayMode NS_AVAILABLE_IOS(10_0);</code>
</pre>
<pre>
NCWidgetDisplayModeCompact:固定高度
NCWidgetDisplayModeExpanded:动态高度
</pre>
通过以下代码可以设置展开还是显示
<pre><code>self.extensionContext.widgetLargestAvailableDisplayMode = NCWidgetDisplayModeExpanded;</code></pre>

2.Message 变更 (主要说明Message + App模式)

通过继承<code>MSMessagesAppViewController</code>,即可实现App
重点需要关注以下方法:
<pre>
<code>
//添加Message对象

  • (void)insertMessage:(MSMessage *)message completionHandler:(nullable void (^)(NSError * _Nullable))completionHandler;
    _
    //添加Sticker对象
  • (void)insertSticker:(MSSticker *)sticker completionHandler:(nullable void (^)(NSError * _Nullable))completionHandler;
    _
    //添加文本信息
  • (void)insertText:(NSString *)text completionHandler:(nullable void (^)(NSError * _Nullable))completionHandler;
    _
    //添加附件
  • (void)insertAttachment:(NSURL *)URL withAlternateFilename:(nullable NSString *)filename completionHandler:(nullable void (^)(NSError * _Nullable))completionHandler;
    </code>
    </pre>

构建消息体

- (MSMessage *)buildMessageWithItem:(Item *)item atIndexPath:(NSIndexPath *)indexPath{
    if (!self.activeConversation){
        return nil;
    }
    MSSession *session = [[MSSession alloc]init];
    if (self.activeConversation.selectedMessage.session){
        session = self.activeConversation.selectedMessage.session;
    }
    MSMessageTemplateLayout *layout = [[MSMessageTemplateLayout alloc]init];
    layout.caption = [NSString stringWithFormat:@"%@",item.caption];
    layout.subcaption = [NSString stringWithFormat:@"%@",item.subcaption];
    layout.image = item.image;
    MSMessage *message = [[MSMessage alloc]initWithSession:session];
    message.URL = [NSURL URLWithString:item.url];
    message.layout = layout;
    return message;
}

说明:<code>MSMessageTemplateLayout</code>为Message消息体的布局模板

SiriSDK(待更新)

Notifications可以在通知中显示图片
主要是<code>UNNotificationServiceExtension</code>和<code>UNMutableNotificationContent</code>的配合使用
通过<code>UNNotificationServiceExtension</code>下载相应的图片
再通过<code>UNMutableNotificationContent</code>展示对应的图片

未完待续

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 上一篇中讲到Message中的一些特性,本次主要讲下Notification的特性 iOS10相对于之前的版本,主...
    i_belive阅读 982评论 0 2
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,403评论 25 708
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,246评论 4 61
  • 每个和你擦肩而过,匆匆走远的路人都在向自己的目标前进。为梦想,路再远,也不要停止前进的脚步。
    瑟西阅读 151评论 0 0
  • 夜 夜的掩盖下 黑吃黑 不论高矮 不比胖瘦 哪管它楚河汉界 在月亮升起来以前 夜鸟还在睡着 风推开窗户 我和你 挥...
    兰若9788阅读 148评论 0 1