美文网首页工作生活
Swift常用第三方框架记录

Swift常用第三方框架记录

作者: Look2021 | 来源:发表于2019-07-02 14:13 被阅读0次

    SwiftyJSON

    // model,josn字符串
    

    高德地图

    https://www.jianshu.com/p/e32af83d8ee0

    pod 'AMap2DMap'
    pod 'AMapLocation' # 高德地图
    // 高德
    #import <AMapFoundationKit/AMapFoundationKit.h>
    #import <AMapLocationKit/AMapLocationKit.h>
    #import <MAMapKit/MAMapKit.h>
    

    SnapKit

    https://www.jianshu.com/p/2bad53a2a180

    View的边距的距离都为20
    view.snp.makeConstraints { (make) in
        make.edges.equalToSuperview().inset(UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20))
    }
    
    make.size.equalTo(CGSize(width: 100, height: 100))
    // 宽高相等时,我们直接写把size写成一遍就行,即 width = height = 100
    make.size.equalTo(100)
    
    // 水平中心线<=view1的左边
    make.centerX.lessThanOrEqualTo(view1.snp.leading)
    
    // 水平中心线<=view1的左边
    make.left.greaterThanOrEqualTo(view1)
    make.left.greaterThanOrEqualTo(view1.snp.left)
    
    // width 是父视图宽的一半
    make.width.equalToSuperview().dividedBy(2)
    // height 是父视图高的三分之一
    make.height.equalToSuperview().dividedBy(3)
    
    // width 是绿色视图宽的10倍
    make.width.equalTo(greenView).multipliedBy(10)
    // height 是绿色视图高的5倍
    make.height.equalTo(greenView).multipliedBy(5)
    
    redView.snp.makeConstraints { (make) in
        // 距离(偏移)父视图顶部 64
        make.top.equalToSuperview().offset(64)
        // 距离(偏移)父视图左边 150
        make.left.equalToSuperview().offset(150)
        // 距离(偏移)父视图右边 150
        make.right.equalToSuperview().offset(-150)
        // 距离(偏移)父视图底部 500
        make.bottom.equalToSuperview().offset(-500)
    
        make.edges.equalToSuperview().inset(UIEdgeInsets(top: 64, left: 150, bottom: 500, right: 150))
    }
    

    JXSegmentedView

    import JXSegmentedView
    
    // tag
    lazy var segmentedView: JXSegmentedView = {
        let segmentedView = JXSegmentedView.init()
        segmentedView.indicators = [indicator]
        segmentedView.backgroundColor = .white
        segmentedView.dataSource = segmentedDataSource
        return segmentedView
    }()
    
    lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
        let segmentedDataSource = JXSegmentedTitleDataSource.init()
        segmentedDataSource.titleNormalFont = UIFont.systemFont(ofSize: 15)~
        segmentedDataSource.titleNormalColor = UIColor.black
        segmentedDataSource.titleSelectedColor = .themeColor
        segmentedDataSource.isTitleColorGradientEnabled = true
        segmentedDataSource.titles = ["设备类型统计", "单位设备统计"]
        // reloadData(selectedIndex:)方法一定要调用,方法内部会刷新数据源数组
        segmentedDataSource.reloadData(selectedIndex: 0)
        return segmentedDataSource
    }()
    
    // 指示器
    lazy var indicator: JXSegmentedIndicatorLineView = {
        let indicator = JXSegmentedIndicatorLineView.init()
        indicator.indicatorColor = .themeColor
        indicator.verticalOffset = 2~
        return indicator
    }()
    
    lazy var listContainerView: JXSegmentedListContainerView = {
        let listContainerView = JXSegmentedListContainerView.init(dataSource: self)
        self.segmentedView.listContainer = listContainerView
        return listContainerView
    }()
    
    extension GGAccessoriesShopViewController: JXSegmentedListContainerViewDataSource {
        
        // 返回列表的数量
        func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
            return self.segmentedDataSource.titles.count
        }
        
        // 返回遵从`JXSegmentedListContainerViewListDelegate`协议的实例
        func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
            
            let model = dataModel[index]
            var param = ProductPageParam.init()
            param.categoryId = model.id
            let vc = GGAccessoriesListViewController.init()
            vc.pageParam = param
            return vc
        }
    }
    
    // MARK:------ JXSegmentedListContainerViewListDelegate ------
    
    func listView() -> UIView {
        return view
    }
    
    //可选使用,列表显示的时候调用
    func listDidAppear() {}
    
    //可选使用,列表消失的时候调用
    func listDidDisappear() {}
    

    相关文章

      网友评论

        本文标题:Swift常用第三方框架记录

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