單糖——良品生活指南:家居零食、禮物美妝、海淘購物
感興趣的朋友可以去 app store 下載
iOS 版下載地址
說明
本程序僅供學習交流,不可用于任何商業用途。
說明
因為公司使用的是 Objective-C 開發 app,沒有使用 swift 來開發,所以決定自己研究 Swift,研究 Swift 的時間不長,對于 Swift 的基本語法有了大致的了解,但是對有些概念和語法還是理解的不深,所以決定模仿一些已經發布的 app,一方面可以讓自己更好地理解和使用 Swift,另一方面可以和志同道合的人一起交流,共同進步。
使用 Swift 模仿的第一個 app 是單糖,總體來說界面搭建還算簡單,而且結構不是很復雜,本次項目完成了大部分界面,對于項目中的數據接口都是通過 Charles 抓包獲得,基本每個界面都是有數據請求,不會抓包的朋友可以看我 這一篇文章。
項目中有的地方代碼寫的不是很簡潔,畢竟自己能力有限,對 Swift 使用不是很熟練,還請各位朋友不喜勿噴。在本文的最后,有項目的完整源碼,喜歡的朋友可以下載下來,如果您感覺我寫的代碼對您有所幫助,還請在 github 給個 star,非常感謝您的支持!~
項目截圖
單糖
首頁
單品
單品詳情
攻略詳情
圖文介紹
評論
分享
分類
搜索
我
設置
項目環境
項目使用 cocoapods 來管理第三方庫,所以需要安裝 cocoapods,安裝方式網上有很多教程,這里不在詳述。運行項目的前,請確保安裝了 cocoapods,否則可能會出現錯誤。
- Xcode 8.2.1
- Swift 3.0
- iOS 8.0
使用到的第三方庫:
- SwiftyJSON - 解析 JSON 數據
- SnapKit - 設置約束
- Kingfisher - 緩存圖片
- SVProgressHUD - 提示框
- FDFullscreenPopGesture - 側滑手勢
- Alamofire - 網絡請求
項目結構
項目結構
由于剛接觸 Swift,以及對 MVVM 的理解的不深,所以沒有使用 MVVM 設計模式,項目使用傳統的 MVC 設計模式。
項目中只在首頁加入了下拉刷新功能,其他界面未加入上拉和下拉刷新功能,后面有時間會完善。
下面是項目的完整結構
- 首頁(單糖)
- Model
- YMChannel.swift
- YMHomeItem.swift
- YMSearchResult.swift
- View
- YMHomeCell.swift
- YMHomeCell.xib
- YMRefreshControl.swift
- YMRefreshView.swift
- YMRefreshView.xib
- YMSearchRecordView.swift
- YMSortCell.swift
- YMSortCell.xib
- YMSortTableView.swift
- Controller
- YMDanTangViewController.swift
- YMTopicViewController.swift
- YMDetailViewController.swift
- YMSearchViewController.swift
- Model
- Product(單品)
- Model
- YMProduct.swift
- YMProductDetail.swift
- YMComment.swift
- View
- YMActionSheet.swift
- YMCollectionViewCell.swift
- YMCollectionViewCell.xib
- YMDetailChoiceButtonView.swift
- YMDetailChoiceButtonView.xib
- YMDetailCollectionViewCell.swift
- YMDetailCollectionViewCell.xib
- YMProductDetailBottomView.swift
- YMProductDetailToolBar.swift
- YMProductDetailToolBar.xib
- YMProductDetailTopView.swift
- YMShareButtonView.swift
- YMDetailScrollView.swift
- YMCommentCell.swift
- YMCommentCell.xib
- Controller
- YMProductViewController.swift
- YMProductDetailViewController.swift
- YMTMALLViewController.swift
- YMTMALLViewController.xib
- Model
- Classify(分類)
- Model
- YMCollection.swift
- YMCollectionPost.swift
- YMGroup.swift
- View
- YMCategoryBottomView.swift
- YMCategoryCollectionViewCell.swift
- YMCategoryCollectionViewCell.xib
- YMCollectionTableViewCell.swift
- YMCollectionTableViewCell.xib
- YMSeeAllTopicCell.swift
- YMSeeAllTopicCell.xib
- YMTopHeaderView.swift
- YMTopHeaderView.xib
- YMVerticalButton.swift
- Controller
- YMCategoryHeaderViewController.swift
- YMCategoryViewController.swift
- YMCollectionDetailController.swift
- YMCollectionDetailController.xib
- YMPostDetailViewController.swift
- YMPostDetailViewController.xib
- YMSeeAllController.swift
- YMSeeAllController.xib
- Model
- Me(我)
- Model
- YMSetting.swift
- View
- YMMeChoiceView.swift
- YMMeFooterView.swift
- YMMineHeaderView.swift
- YMSettingCell.swift
- YMSettingCell.xib
- Controller
- YMMessageViewController.swift
- YMMeViewController.swift
- YMSettingViewController.swift
- Model
- Login&Register(登錄和注冊)
- Controller
- YMLoginViewController.swift
- YMLoginViewController.xib
- YMRegisterViewController.swift
- YMRegisterViewController.xib
- YMNewfeatureViewController.swift
- Controller
- Main(主要)
- Category
- String+Extension.swift
- UITableView+EmptyData.swift
- UIView+Extension.swift
- Controller
- YMBaseViewController.swift
- YMNavigationController.swift
- YMTabBarController.swift
- Tools
- YMConst.swift
- YMNetworkTool.swift
- Category