美文网首页
一个iOS项目技术栈分析

一个iOS项目技术栈分析

作者: 玉思盈蝶 | 来源:发表于2020-12-20 16:39 被阅读0次

    1、Podfile文件:

    # Uncomment the next line to define a global platform for your project
    platform :ios, '11.0'
    use_frameworks! :linkage => :static
    
    def common_pods
      pod 'SwifterSwift'
      pod 'SnapKit'
      pod 'IQKeyboardManagerSwift'
    end
    
    def network_pods
      pod 'Moya'
      pod 'PromiseKit'
      pod 'PromiseKit/UIKit'
      pod 'Alamofire'
      pod 'PromiseKit/Alamofire'
      pod 'HandyJSON'
    end
    
    def ui_pods
      pod 'KDCalendar'
      pod 'FSPagerView'
      pod 'JXSegmentedView', :git => 'https://github.com/pujiaxin33/JXSegmentedView', :branch => 'master'
      pod 'JXPagingView/Paging'
      pod 'Toast-Swift'
      pod 'Kingfisher'
      pod "ESPullToRefresh"
      pod "SideMenu"
    end
    
    def other_pods
      pod 'JPush'
      pod 'AMapNavi'
      pod 'AMapLocation'
    end
    
    
    target 'XXX' do
      # Comment the next line if you don't want to use dynamic frameworks
    
      # Pods for XXX
      common_pods
      ui_pods
      network_pods
      other_pods
    end
    

    2、iOS13适配暗黑模式:

    if #available(iOS 13.0, *) {
        window?.overrideUserInterfaceStyle = .light;
    }
    

    3、判断当前环境:

    public var isInProductionMode: Bool {
        // http://stackoverflow.com/questions/9063100/xcode-ios-how-to-determine-whether-code-is-running-in-debug-release-build
        #if DEBUG
            return false
        #else
            return true
        #endif
    }
    

    4、Timer tolerance属性:

    ※这是7.0之后的一个新特性,由于NSTimer不精确,通过它设置误差范围
    
    @property NSTimeInterval tolerance ;
    

    5、判断属性是否是0:

    var receivedTime: TimeInterval = 0
    
    if !_orderInfo.receivedTime.isZero {
        sendTimeRows.append(.receive)
    }
    

    6、UITableView分类使用枚举:

    /// 数据源使用枚举数组,方面后面创建cell之类的使用。
    enum Section {
        /// 地址信息
        case address
        /// 配送记录
        case record
        /// 菜品
        case dish
        /// 优惠折扣
        case discount
        /// 总价
        case total
        /// 订单备注/时间
        case info
    }
    

    7、线条的高度:

    let lineHeight = 1/UIScreen.main.scale
    

    8、闭包定义:

    typealias JSONDictionary = [String: Any]
    
    /// 分页返回, next: 是否有下一页
    typealias Page<T> = (list:Array<T>,next:Bool,total: Int)
    
    typealias DoubleArray<T,S> = (left:Array<T>,right:Array<S>)
    
    typealias CallBack<T> = (T)->()
    

    使用:

    private var phoneCallBack:CallBack<StoreModel>?
    

    页面路由跳转封装:

    import UIKit
    
    class Router {
        private let mapVc = RideRoutePlanViewController()
        
        private static let shared = Router()
        
        class func openMap() {
            mainWindow?.rootViewController?.present(shared.mapVc, animated: true, completion: nil)
        }
        
        class func call(phone: String) {
            guard let url = URL(string: "tel://\(phone)") else {
                mainWindow?.show(text: "电话号码有误")
                return
            }
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }
    }
    

    相关文章

      网友评论

          本文标题:一个iOS项目技术栈分析

          本文链接:https://www.haomeiwen.com/subject/yleknktx.html