开坑
- SafeSyncQueue
- WebView
protocol
- ImageDownloadRequestModifier
遵循 ImageDownloadRequestModifier Protocl 并实现协议方法,可自定义一个 modefiedRequest,比如插入 header
private struct DownloadRequestModifier: ImageDownloadRequestModifier {
func modified(for request: URLRequest) -> URLRequest? {
var modifiedRequest = request
UserContext.httpAuthHeader.forEach { modifiedRequest.addValue($0.value, forHTTPHeaderField: $0.key) }
return modifiedRequest
}
}
property
- edgesForExtendedLayout
它只有当viewController被嵌到别的container view controller中时才会起作用。
This property is applied only to view controllers that are embedded in a container such as UINavigationController. The window’s root view controller does not react to this property. The default value of this property is UIRectEdgeAll.
比如可以设置控制器的 edgesForExtendedLayout 属性为 UIRectEdgeNone,这样 self.view 就会从导航栏的 botttom 处开始布局。
- lastPathComponent
developer.apple.com/documentati…
function
- presentation()
每一个视图都有一个父视图以及若干个子视图,这形成了一个树状的层级关系。对应地,每个视图的图层也有一个平行的层级关系,称之为图层树(Layer Tree)。直接创建的或者通过 UIView 获得的(view.layer)用于显示的图层树,称之为模型树(Model Tree),模型树的背后还存在两份图层树的拷贝,一个是呈现树(Presentation Tree),一个是渲染树(Render Tree)。
模型树则可以通过 modelLayer 属性获得,而呈现树可以通过模型树的 layer.presentationLayer 获得。模型树的属性值就是我们看到的动画起始和结束时的值,是静态的;呈现树的属性值和动画运行过程中界面上看到的是一致的,是动态的。而渲染树是私有的,你无法访问到,渲染树是对呈现树的数据进行渲染,为了不阻塞主线程,渲染的过程是在单独的进程或线程中进行的,所以你会发现 Animation 的动画并不会阻塞主线程。
- init(fileURLWithPath:relativeTo:)
let url = URL(string: "www.baidu.com")
let modifiedURL = URL(fileURLWithPath: "test", relativeTo: url)
------
www.baidu.com
test -- www.baidu.com
- deletingLastPathComponent()
let url = URL(string: "www.baidu.com/test")
let modifiedURL = url?.deletingLastPathComponent()
---
www.baidu.com/test
www.baidu.com/
link
iOS 拾遗 —— Assets Catalogs 与 I/O 优化
怎么让self.view的Y从navigationBar下面开始计算