Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
I may be slow to respond.

DianQK DianQK

:shipit:
I may be slow to respond.
View GitHub Profile
View SearchParentView.swift
import UIKit
func recurisiveSearchParentViewUntil<T: UIView>(type: T.Type, currentView: UIView) -> T? {
switch currentView {
case let view as T:
return view // 当前 view 满足则返回 view
case let view where view.superview != nil:
return recurisiveSearchParentViewUntil(type, currentView: view.superview!)
default:
return nil
View Example.swift
let CampusNetworkProvider = MoyaProvider<CampusNetwork>(endpointClosure: MoyaProvider.DefaultEndpointMapping,
requestClosure: requestClosure,
stubClosure: MoyaProvider.NeverStub,
manager: MoyaProvider<CampusNetwork>.DefaultAlamofireManager(),
plugins: [NetworkLoggerPlugin()])