专栏名称: 知识小集
目录
相关文章推荐
龙视新闻联播  ·  哈尔滨冰雪大世界发布闭园公告 ·  昨天  
南京日报  ·  钟山脚下又添打卡地!目测要火 ·  2 天前  
爱浪客  ·  速度 | ... ·  2 天前  
今日五莲  ·  闭园公告! ·  2 天前  
今日五莲  ·  闭园公告! ·  2 天前  
51好读  ›  专栏  ›  知识小集

「 iOS知识小集 」2018 · 第 40 期

知识小集  · 掘金  ·  · 2018-12-10 05:55

正文

阅读 193

「 iOS知识小集 」2018 · 第 40 期

原文链接

在过去的一周,Google 在 Flutter Live 2018 上正式发布了 Flutter 1.0。这也意味 Flutter 步入正轨,我们可以更多地去尝试这门技术。关于 Flutter 1.0 更多的信息,可以查看 Flutter 1.0 正式版: Google 的便携 UI 工具包

上周公众号发布的以下文章:

本期知识小集的主要内容包括:

  • 关于 UIApplicationState 在 iOS 12.0 系统中的 Bug
  • 为 UIView “截屏”
  • 覆盖父类同名属性

关于 UIApplicationState 在 iOS 12.0 系统中的 Bug

作者: ibabyblue_z

UIApplicationState 分为三种状态:

  1. UIApplicationStateActive:App处于活跃状态(在前台并正在接收事件)
  2. UIApplicationStateInactive:App处于非活跃状态(在前台并未接收事件/正在前台进入后台、后台进入前台时)
  3. UIApplicationStateBackground:App处于后台状态

项目有个需求,当 App 在后台时,接收到消息需要弹本地通知。突然线上反馈说功能失效了,并且还是个别用户。经验证这是iOS12.0系统的 Bug,已经在 iOS 12.1 中修复了!

之前的逻辑是判断 App 是否在后台,使用了 UIApplicationStateBackground,但是在 iOS 12.0中,当 App 在后台时,获取系统状态返回为 UIApplicationStateInactive。

为 UIView “截屏”

作者: halohily

想为某个 UIView 的内容生成一张图片,系统提供了非常方便的解决方式:使用 CoreGraphics

UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0);

//获取当前上下文
CGContextRef ctx = UIGraphicsGetCurrentContext();
//渲染
[view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return newImage;
复制代码

若要为 UIView 生成 UIView 形式的快照,可以使用 UIView 的实例方法簇:

- (nullable UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates NS_AVAILABLE_IOS(7_0);
复制代码

覆盖父类同名属性

作者 : Vong_HUST

日常开发中,我们都可能会碰到这种情况,继承系统的某个类,但是想要覆盖父类的某个属性名(大部分情况是 delegate dataSource )会发现两个烦人的 warning ,代码如下所示。

@protocol VVLTextViewDelegate;

@interface VVLTextView : UITextView

// warning1: Property type 'id<VVLTextViewDelegate>' is incompatible with type 'id<UITextViewDelegate> _Nullable' inherited from 'UITextView'
// warning2: Auto property synthesis will not synthesize property 'delegate'; it will be implemented by its superclass, use @dynamic to acknowledge intention
@property (nonatomic, weak) id<VVLTextViewDelegate> delegate;

@end






请到「今天看啥」查看全文