文章来源:淘论文网   发布者: 毕业设计   浏览量: 22



还可以点击去查询以下关键词:
[swift3.0]    [高仿斗]    [毕业]    [最新版]    [swift3.0高仿斗毕业鱼TV 最新版]   

项目介绍:

最新版的斗鱼直播是2.410,界面是按照这个版本来仿的,使用Alamofire、Kingfisher第三方框架,架构使用MVVM,学习swift3.0的最佳练手项目,欢迎大家github上面去download后观摩

github: https://github.com/targetcloud/DYZB

使用Alamofire、Kingfisher第三方框架,论文,架构利用使用MVVM,学习swift3.0的最佳练手项目,开题报告,欢迎大家github上面去download后观摩

// HttpTools.swift // Copyright © 2016年 targetcloud. All rights reserved. import UIKit import Alamofire enum MethodType { case get case post } class HttpTools { class func requestData(_ type : MethodType, URLString : String, parameters : [String : Any]? = nil, finishedCallback : @escaping (_ result : Any) -> ()) { let method = type == .get ? HTTPMethod.get : HTTPMethod.post Alamofire.request(URLString, method: method, parameters: parameters).responseJSON { (response) in guard let result = response.result.value else { print(response.result.error) return } finishedCallback(result) } } } // BaseAnchorVC.swift // Copyright © 2016年 targetcloud. All rights reserved. import UIKit private let kItemMargin : CGFloat = 10 private let kHeaderViewH : CGFloat = 50 private let NormalCellID = 'NormalCellID' private let HeaderViewID = 'HeaderViewID' let kNormalItemW = (kScreenW - 33 * kItemMargin) / 2 let kNormalItemH = kNormalItemW * 3 / 4 let kPrettyItemH = kNormalItemW * 5 / 4 let PrettyCellID = 'PrettyCellID' class BaseAnchorVC: BaseVC { //!表示用到的时候保证有值 var baseVM : BaseVM! lazy var collectionView : UICollectionView = {[unowned self] in let layout = UICollectionViewFlowLayout() layout.itemSize = CGSize(width: kNormalItemW, height: kNormalItemH) layout.minimumLineSpacing = 0 layout.minimumInteritemSpacing = kItemMargin layout.headerReferenceSize = CGSize(width: kScreenW, height: kHeaderViewH) layout.sectionInset = UIEdgeInsets(top: 0, left: kItemMargin, bottom: 0, right: kItemMargin) let collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: layout) collectionView.backgroundColor = UIColor.white collectionView.dataSource = self collectionView.delegate = self collectionView.autoresizingMask = [.flexibleHeight, .flexibleWidth] collectionView.register(UINib(nibName: 'CollectionNormalCell', bundle: nil), forCellWithReuseIdentifier: NormalCellID) collectionView.register(UINib(nibName: 'CollectionPrettyCell', bundle: nil), forCellWithReuseIdentifier: PrettyCellID) collectionView.register(UINib(nibName: 'CollectionHeaderView', bundle: nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: HeaderViewID) return collectionView }() override func viewDidLoad() { super.viewDidLoad() setupUI() loadData() } } extension BaseAnchorVC { override func setupUI() { contentView = collectionView view.addSubview(collectionView) super.setupUI() } } extension BaseAnchorVC { func loadData() { } } extension BaseAnchorVC : UICollectionViewDataSource { func numberOfSections(in collectionView: UICollectionView) -> Int { return baseVM.anchorGroups.count } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return baseVM.anchorGroups[section].anchors.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NormalCellID, for: indexPath) as! CollectionNormalCell cell.anchor = baseVM.anchorGroups[indexPath.section].anchors[indexPath.item] return cell } func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: HeaderViewID, for: indexPath) as! CollectionHeaderView headerView.group = baseVM.anchorGroups[indexPath.section] return headerView } } extension BaseAnchorVC : UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let anchor = baseVM.anchorGroups[indexPath.section].anchors[indexPath.item] anchor.isVertical == 0 ? pushNormalRoomVc(anchor) : presentShowRoomVc(anchor) } private func presentShowRoomVc(_ anchor : AnchorModel) { let showVc = ShowRoomVC() showVc.anchor = anchor present(showVc, animated: true, completion: nil) } private func pushNormalRoomVc(_ anchor : AnchorModel) { let normalVc = NormalRoomVC() normalVc.anchor = anchor navigationController?.pushViewController(normalVc, animated: true) } } // GameVC.swift // Copyright © 2016年 targetcloud. All rights reserved. import UIKit class GameVC: BaseAnchorVC { fileprivate lazy var gameVM : GameVM = GameVM() fileprivate lazy var menuView : MenuView = { let menuView = MenuView.menuView() menuView.frame = CGRect(x: 0, y: -kMenuViewH, width: kScreenW, height: kMenuViewH)//设置collectionView的-y,放置menuView return menuView }() } extension GameVC { override func setupUI() { super.setupUI() collectionView.addSubview(menuView) collectionView.contentInset = UIEdgeInsets(top: kMenuViewH, left: 0, bottom: 0, right: 0)//设置内边距 } } extension GameVC{ override func loadData() { baseVM = self.gameVM gameVM.requestData { self.collectionView.reloadData() var gameGroups = Array(self.gameVM.anchorGroups[1...15])//0...15 & gameGroups.removeFirst() let moreGroup = AnchorGroup() moreGroup.tag_name = '更多分类' gameGroups.append(moreGroup) self.menuView.groups = gameGroups self.loadDataFinished() } } } [objc] view plain copy 在CODE上查看代码片派生到我的代码片 // BaseVM.swift // Copyright © 2016年 targetcloud. All rights reserved. import UIKit class BaseVM { lazy var anchorGroups : [AnchorGroup] = [AnchorGroup]() func loadAnchorData(isGroupData : Bool, URLString : String, parameters : [String : Any]? = nil, finishedCallback : @escaping () -> ()) { HttpTools.requestData(.get, URLString: URLString, parameters: parameters) { (result) in guard let dict = result as? [String : Any] else { return } guard let arr = dict['data'] as? [[String : Any]] else { return } if isGroupData { for dict in arr { self.anchorGroups.append(AnchorGroup(dict: dict)) } } else { let group = AnchorGroup() for dict in arr { group.anchors.append(AnchorModel(dict: dict)) } self.anchorGroups.append(group) } finishedCallback() } } }


这里还有:


还可以点击去查询:
[swift3.0]    [高仿斗]    [毕业]    [最新版]    [swift3.0高仿斗毕业鱼TV 最新版]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/8456.docx
  • 上一篇:一种支持单列数据选择,多毕业设计列数据选择,plist读取数据选择...
  • 下一篇:简洁强大的毕业设计约束工具