<file_sep>//
//  MineInfoViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/28.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class MineInfoViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UIImagePickerControllerDelegate,UINavigationControllerDelegate {
    //cellIdentifier 设置
    let headerImageCellIdentifier = "headerImageCell"
    let nicknameCellIdentifier = "nicknameCell"
    let mobileCellIdentifier = "mobileCell"
    let passwordCellIdentifier = "passwordCell"
    let showEditPasswordSegueIdentifier =  "showEditPasswordSegue"
    let showEditPhoneSegueIdentifier = "showEditPhoneSegue"
    let showEditNicknameIdentifier = "showEditNicknameSegue"
    @IBOutlet weak var tableView: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addBackItem()
        //设置tableview尾部为无
        self.tableView.tableFooterView = UIView()
        
    }

//MARK:- UITableViewDataSource
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 4
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        switch indexPath.row {
        case 0:
            let cell = tableView.dequeueReusableCell(withIdentifier: headerImageCellIdentifier , for: indexPath)
            return cell
        case 1:
            let cell = tableView.dequeueReusableCell(withIdentifier: nicknameCellIdentifier , for: indexPath)
            return cell
        case 2:
            let cell = tableView.dequeueReusableCell(withIdentifier: mobileCellIdentifier , for: indexPath)
            return cell

        default:
            let cell = tableView.dequeueReusableCell(withIdentifier: passwordCellIdentifier , for: indexPath)
            return cell
        }
    }
//MARK:- UITableViewDelegate
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 50
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        switch indexPath.row {
        case 0:
            showSheet()
        case 1:
            self.performSegue(withIdentifier: showEditNicknameIdentifier, sender: self)
        case 2:
            self.performSegue(withIdentifier: showEditPhoneSegueIdentifier, sender: self)
        case 3:
            self.performSegue(withIdentifier: showEditPasswordSegueIdentifier, sender: self)
        default:
            print("default")
        }
    }
//MARK:- 展示sheet
    func showSheet() {
        let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)        
        //取消
        let actionCancel = UIAlertAction(title: "取消", style: .cancel, handler: nil)
        //相册
        let actionPhotoLibray = UIAlertAction(title: "相册中选择图片", style: .default) { (UIAlertAction) -> Void in
            if UIImagePickerController.isSourceTypeAvailable(.photoLibrary){
                let imagePicker = UIImagePickerController()
                imagePicker.delegate = self
                imagePicker.allowsEditing = false
                imagePicker.sourceType = .photoLibrary
                self.present(imagePicker, animated: true, completion: nil)
                
            }
            
        }
        //相机
        let actionCamera = UIAlertAction(title: "相机拍摄", style: .default) { (UIAlertAction) -> Void in
            if UIImagePickerController.isSourceTypeAvailable(.camera){
                let imagePicker = UIImagePickerController()
                imagePicker.delegate = self
                imagePicker.allowsEditing = false
                imagePicker.sourceType = .camera
                self.present(imagePicker, animated: true, completion: nil)
            }
            
        }
        
        alert.addAction(actionPhotoLibray)
        alert.addAction(actionCamera)
        alert.addAction(actionCancel)
        self.present(alert, animated: true,completion: nil)
    }
    //MARK:- UIImagePickerControllerDelegate
    //选择图片回调
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
       
        (self.tableView.cellForRow(at: IndexPath(row: 0, section: 0)) as! InfoHeaderTableViewCell ).headerImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
        dismiss(animated: true, completion: nil)
        
    }
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if let vc = segue.destination as? EditPhoneOneViewController{
            vc.phoneString = "15857476747"
        }else if let vc = segue.destination as? EditNicknameViewController{
            vc.oldNickname = "小<PASSWORD>"
        }
        
    }

}
<file_sep>//
//  NavigationControllerExtension.swift
//  SuperWeChat
//
//  Created by 周鹏杰 on 16/9/18.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit


extension UINavigationController{
    func customPopViewController(animated:Bool){
        self.popViewController(animated: true)
    }
//去除下方横线
    open override func viewDidLoad()  {
        self.navigationBar.setBackgroundImage(UIImage(), for: .default)
        self.navigationBar.shadowImage = UIImage()
        
       
    }
}



<file_sep>//
//  ClassDetailTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/13.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class ClassDetailTableViewCell: UITableViewCell,UICollectionViewDataSource {

    @IBOutlet weak var subClassTitleLabel: UILabel!
    @IBOutlet weak var collectionView: UICollectionView!
    override func awakeFromNib() {
        super.awakeFromNib()
        let itemSize = CGSize(width: ITEM_WIDTH, height: ITEM_WIDTH*(125/100))
        let layout = PublicCollectionViewLayout(sectionInset: UIEdgeInsets(top: 20, left: 10, bottom: 20, right: 10), minimumLineSpacing: 20, minimumInteritemSpacing: 10.5, itemSize: itemSize)
        self.collectionView.collectionViewLayout = layout
        self.collectionView.dataSource = self
        self.collectionView.isScrollEnabled = false
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }
    
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        return 6
    }
    
    

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "classDetailItemCell", for: indexPath)
        return cell
    }


}
<file_sep>//
//  TopImageButton.swift
//  SuperWeChat
//
//  Created by 周鹏杰 on 16/9/19.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
@IBDesignable
class TopImageButton: UIButton {
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setImage(UIImage(named: "friend"), for: .normal)
        self.setTitle("朋友圈", for: .normal)
        self.setTitleColor(.red, for: .normal)
        self.titleLabel?.font = UIFont.systemFont(ofSize: 18 )
        initButton()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    @IBInspectable var space:CGFloat = 0{
        didSet{
            self.initButton()
        }
    }
    func initButton(){
        self.contentVerticalAlignment = .top
        self.contentHorizontalAlignment = .center
        let imageViewWidth :CGFloat! = self.imageView?.intrinsicContentSize.width
        let imageViewHeight :CGFloat! = self.imageView?.intrinsicContentSize.height
        let titleLabelWidth :CGFloat! = self.titleLabel?.intrinsicContentSize.width
//        let titleLabelHeight:CGFloat!  = self.titleLabel?.intrinsicContentSize.height
        //文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变
        self.titleEdgeInsets = UIEdgeInsets(top: imageViewHeight + space, left: -imageViewWidth, bottom: 0, right: 0)
        //图片距离右边框距离减少文字的宽度，其它不变
        self.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -titleLabelWidth)
        self.contentEdgeInsets = UIEdgeInsets.zero
     }

}
<file_sep>//
//  File.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/1.
//  Copyright © 2016年 周. All rights reserved.
//

import Foundation
extension UITextField{
    
    /// 设置textField的placeHolder颜色
    ///
    /// - Parameter color: 颜色
    func setPlaceholderColor(color:UIColor){
        let newPlaceholder = NSAttributedString(string: self.placeholder!, attributes: [NSForegroundColorAttributeName:color])
        self.attributedPlaceholder = newPlaceholder
    }
  }
<file_sep>//
//  GoodsBottomTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/12/10.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class GoodsBottomTableViewCell: UITableViewCell ,UITableViewDelegate,UITableViewDataSource{

   
    //cell标识符
    let evaluateCellIdentifier = "evaluateCell"
    var topBarView = UIView()
    var goodsInfoButton = UIButton()
    var evaluateButton = UIButton()
    var contentTableView = UITableView()
    var allButton = UIButton()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(topBarView)
        self.topBarView.addSubview(goodsInfoButton)
        self.topBarView.addSubview(evaluateButton)
        self.contentView.addSubview(contentTableView)
        self.contentView.addSubview(allButton)
        self.setAllAttributes()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFrame()
    }
    
    func setLayout(){
        topBarView.snp.makeConstraints { (make) in
            make.left.top.right.equalToSuperview()
            make.height.equalTo(41)
        }
        goodsInfoButton.snp.makeConstraints { (make) in
            make.left.top.equalToSuperview()
            make.width.equalTo(SCREEN_WIDTH/2 - 0.5)
            make.height.equalTo(40)
        }
        evaluateButton.snp.makeConstraints { (make) in
            make.right.top.equalToSuperview()
            make.width.equalTo(SCREEN_WIDTH/2 - 0.5)
            make.height.equalTo(40)
        }
        contentTableView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets(top: 41, left: 0, bottom: 45, right: 0))
        }
        allButton.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-10)
            make.height.equalTo(25)
            make.width.equalTo(70)
        }
        
    }
    func setData(){
        
    }
    func setFrame(){
        //设置背景色方便分割线的显示
        self.topBarView.backgroundColor = HiTaoBackgroundColor
        self.goodsInfoButton.backgroundColor = .white
        self.goodsInfoButton.setTitleColor(.black, for: .normal)
        self.goodsInfoButton.setTitle("商品信息", for: .normal)
        self.goodsInfoButton.titleLabel?.font = BigFont
        self.goodsInfoButton.addTarget(self, action: #selector(GoodsBottomTableViewCell.infoBtn(_:)), for: .touchUpInside)
        self.evaluateButton.backgroundColor = .white
        self.evaluateButton.setTitleColor(.black, for: .normal)
        self.evaluateButton.setTitle("宝贝评价(122)", for: .normal)
        self.evaluateButton.titleLabel?.font = BigFont
        self.evaluateButton.addTarget(self, action: #selector(GoodsBottomTableViewCell.evaluateBtn(_:)), for: .touchUpInside)

        self.contentTableView.separatorStyle = .none
        self.contentTableView.isScrollEnabled = false
        self.contentTableView.register(EvaluateTableViewCell.self, forCellReuseIdentifier: evaluateCellIdentifier)
        self.contentTableView.delegate = self
        self.contentTableView.dataSource  = self
        self.allButton.setTitle("查看全部评价", for: .normal)
        self.allButton.titleLabel?.font = SmallFont
        self.allButton.setBackgroundImage(UIImage(named:"btn_nor_gray_140x50"), for: .normal)
        
    }
    
    /// 商品信息按钮响应方法
    ///
    /// - Parameter sender: 传递对象
    func infoBtn(_ sender:UIButton){
         self.goodsInfoButton.setTitleColor(customRed, for: .normal)
         self.evaluateButton.setTitleColor(.black, for: .normal)
        print("商品信息.....")

        
    }
    
    /// 宝贝详情按钮响应方法
    ///
    /// - Parameter sender: 传递对象
    func evaluateBtn(_ sender:UIButton){
        self.evaluateButton.setTitleColor(customRed, for: .normal)
        self.goodsInfoButton.setTitleColor(.black, for: .normal)
        print("宝贝评价.....")
        
        
    }
    //MARK: - UITableViewDataSource
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return  2
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: evaluateCellIdentifier, for: indexPath)
        //cell选中样式设置
        cell.selectionStyle = .none
        return cell
    }
    //MARK: - UITableViewDelegate

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 90
    }

}
<file_sep>//
//  AddressManageViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/31.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class AddressManageViewController: UIViewController,UITableViewDataSource ,UITableViewDelegate{
    var count:Int = 4
    let addressCellIdentifier = "addressCell"
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addBackItem()
        self.setRightItem(fontSize:12)
    }
    @IBOutlet weak var tableView: UITableView!
  
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //MARK:- UITableViewDataSource
    func numberOfSections(in tableView: UITableView) -> Int {
        return count
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: addressCellIdentifier, for: indexPath)
        return cell
    }
    //MARK:- UITableViewDelegate
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 105
    }
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        switch section {
        case 0:
            return 1
        default:
            return 10
        }
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.000001
    }
    @IBAction func unWindMethod(segue:UIStoryboardSegue){
        self.count += 1
        self.tableView.reloadData()
    
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
<file_sep>//
//  NewCheapTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/16.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class NewCheapTableViewCell: UITableViewCell {
    var  headerImageView = UIImageView()
    var  goodsNameLabel = UILabel()
    var  newPriceLabel = UILabel()
    var  oldPriceLabel = UILabel()
    var  lineView = UIView()
    var  buyButton = UIButton()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(headerImageView)
        self.contentView.addSubview(goodsNameLabel)
        self.contentView.addSubview(newPriceLabel)
        self.contentView.addSubview(oldPriceLabel)
        self.contentView.addSubview(lineView)
        self.contentView.addSubview(buyButton)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFrame()
    }
    
    func setLayout(){
        headerImageView.snp.makeConstraints { (make) in
            make.width.equalToSuperview()
            make.height.equalTo(150)
            make.left.top.equalToSuperview()
        }
        lineView.snp.makeConstraints { (make) in
            make.height.equalTo(10)
            make.width.equalTo(1)
            make.centerX.equalToSuperview()
            make.top.equalTo(headerImageView.snp.bottom).offset(10)
        }
        goodsNameLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(lineView)
            make.right.equalTo(lineView.snp.left).offset(-20)
        }
        newPriceLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(lineView)
            make.left.equalTo(lineView.snp.right).offset(20)
        }
        oldPriceLabel.snp.makeConstraints { (make) in
            make.left.equalTo(newPriceLabel.snp.right).offset(5)
            make.centerY.equalTo(newPriceLabel)
        }
        buyButton.snp.makeConstraints { (make) in
            make.width.equalTo(80)
            make.height.equalTo(40)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-10)
        }
        
        
    }
    func setData(){
        self.headerImageView.image = UIImage(named:imageDefaultName)
        self.goodsNameLabel.text = "新上市蓝莓"
        self.newPriceLabel.text = "￥100"
        self.oldPriceLabel.text = "￥180"
        
    }
    func setFrame(){
        self.goodsNameLabel.font = BigFont
        self.lineView.backgroundColor = customGray
        self.newPriceLabel.setNewLabel(headerFontSize: 9, footerFontSize: 11)
        self.oldPriceLabel.setOldLabel(fontSize: 9)
        self.buyButton.setBackgroundImage(UIImage(named:"btn_sel_red_160x80"), for: .normal)
        self.buyButton.titleLabel?.font = BigFont
        self.buyButton.setTitle("抢购", for: .normal)
        self.buyButton.titleEdgeInsets.top -= 5

    }

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }

}
<file_sep>//
//  CouponTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/8.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class CouponTableViewCell: UITableViewCell {
    var bgView = UIImageView()
    
    var nameLabel = UILabel()
    var amountLabel = UILabel()
    var totalLabel = UILabel()
    var dayLabel = UILabel()
    var useButton = UIButton()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
       super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(bgView)
        self.bgView.addSubview(nameLabel)
        self.bgView.addSubview(amountLabel)
        self.bgView.addSubview(totalLabel)
        self.bgView.addSubview(useButton)
        self.bgView.addSubview(dayLabel)
        self.setAllAttributes()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData(amount: 11, total: 11)
        self.setFrame()
    }
    
    func setLayout(){
        bgView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets(top: 10, left: 0, bottom: 0, right: 10))
        }
        amountLabel.snp.makeConstraints { (make) in
            make.bottom.equalTo(bgView.snp.centerY).offset(-5)
            make.centerX.equalTo(bgView.snp.left).offset(75)
        }
        totalLabel.snp.makeConstraints { (make) in
            make.centerX.equalTo(amountLabel)
            make.top.equalTo(bgView.snp.centerY).offset(5)
        }
        dayLabel.snp.makeConstraints { (make) in
            make.bottom.equalTo(bgView.snp.centerY).offset(-10)
            let rightSpace = SCREEN_WIDTH - 135
            make.centerX.equalTo(bgView.snp.right).offset(-(rightSpace - 35)/2 - 35)
        }
        nameLabel.snp.makeConstraints { (make) in
            make.bottom.equalTo(dayLabel.snp.top).offset(-10)
            make.centerX.equalTo(dayLabel)
        }
        useButton.snp.makeConstraints { (make) in
            make.width.equalTo(70)
            make.height.equalTo(30)
            make.top.equalTo(bgView.snp.centerY).offset(10)
            make.centerX.equalTo(nameLabel)
        }
    }
    func setData(amount:Double,total:Double){
        self.amountLabel.text = "￥5.00"
        self.totalLabel.text = "满78元可用"
        self.dayLabel.text = "2016.10.20-2016.10.23 (剩余3天)"
        self.nameLabel.text = "新人有礼十一专享劵"
    }
    func setFrame(){
        self.contentView.backgroundColor = HiTaoBackgroundColor
        bgView.image =  UIImage(named:"img_bg_white")
        self.amountLabel.customColorAndSizeSmall(smallFontSize: 9, bigFontSize: 22, ranges: [NSRange(location: 0, length: 1)], smallColor: customRed, bigColor: customRed)
        self.totalLabel.setFontAndTextColor(font: BigFont, textColor:customGray)
        self.dayLabel.font = SmallFont
        self.dayLabel.setColorsLabel(colors: [customGray,customRed], range: [NSMakeRange(0, 21),NSMakeRange(22, (self.dayLabel.text?.characters.count)! - 22)])
        self.nameLabel.setFontAndTextColor(font: BigFont, textColor: .black)
        self.useButton.setBackgroundImage(UIImage(named:"btn_nor_red_140x60"), for:.normal)
        self.useButton.setTitle("立即使用", for: .normal)
        self.useButton.titleLabel?.font = BigFont
    }
    func setGrayColor(){
        self.amountLabel.textColor = customGray
        self.dayLabel.textColor = customGray
        self.nameLabel.textColor = customGray
        self.useButton.setBackgroundImage(UIImage(named:"btn_nor_gray_140x60"), for:.normal)
        self.useButton.setTitle("已过期", for: .normal)

    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }

}
<file_sep>//
//  MenuContentView.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/27.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class MenuContentView: UIView {
    //合计高度
    var allHeight:CGFloat!
    //数据源
    var menuArray = ["新品发布","热销排行","本周排行","整","新品发布","热销排行","本周排行","整"]
    //button高度
    let buttonHeight:CGFloat = 30
    //button垂直距离
    let buttonVerticalSpace:CGFloat = 20
    //button水平距离
    let buttonHorizontalSpace:CGFloat = 20
    //前面button的宽度数组 （换行清空）
    var buttonWidthArray :[CGFloat] = []
    //开始位置左边空间大小
    var leftStartSpace :CGFloat = 10
    //头部空间大小
    var topSpace:CGFloat = 10
    //回调方法
    var completion :(()->())!
    //重写父类初始化方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addButton()
        self.height = topSpace + 50
        self.frame.size.height = height
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //动态添加button
    func addButton(){
        //恢复初始值
        leftStartSpace  = 10
        topSpace = 10
        buttonWidthArray.removeAll(keepingCapacity: true)
        for index in 0..<menuArray.count {
            var leftSpace = leftStartSpace
            for buttonWidth in buttonWidthArray {
                leftSpace += buttonWidth + buttonHorizontalSpace
            }
            //根据内容的长度获取button的长度
            let width = menuArray[index].getStringWidth(font: MiddleFont) + 30
            //判断剩余的长度是否足够放下一个button
            if leftSpace + buttonHorizontalSpace + width + 10 > SCREEN_WIDTH{
                buttonWidthArray.removeAll(keepingCapacity: true)
                topSpace += buttonVerticalSpace + buttonHeight
                leftStartSpace = 10
                leftSpace = leftStartSpace
            }
            //设置button样式
            let iconButton = UIButton()
            iconButton.titleLabel?.font = MiddleFont
            iconButton.setTitle(menuArray[index], for: .normal)
            iconButton.setTitleColor(customGray, for: .normal)
            iconButton.setBackgroundImage(UIImage(named:"background_icon"), for: .normal)
            //设置tag区分标签
            iconButton.tag = index
            self.addSubview(iconButton)
            //添加button响应事件
            iconButton.addTarget(self, action: #selector(MenuContentView.selectMenu(_:)), for: .touchUpInside)
            //将新的button宽度添加到数组
            buttonWidthArray.append(width)
            //添加约束
            iconButton.snp.makeConstraints({ (make) in
                make.width.equalTo(width)
                make.height.equalTo(buttonHeight)
                make.left.equalTo(leftSpace)
                make.top.equalTo(topSpace)
            })
            
        }
    }
    
    /// 响应事件
    ///
    /// - Parameter sender: 响应发起对象
    func selectMenu(_ sender:UIButton){
        switch sender.tag {
        case 0:
            print("选中条件1")
            self.changeButtonColor(sender: sender)
            completion()
        default:
            print("选中其他条件")
            self.changeButtonColor(sender: sender)
            completion()
        }
    }
    //改变button的背景图片
    func changeButtonColor(sender:UIButton){
        for view in self.subviews{
            if let view  = view as? UIButton{
                view.setBackgroundImage(UIImage(named:"background_icon"), for: .normal)
                view.setTitleColor(customGray, for: .normal)
                
            }
        }
        sender.setBackgroundImage(UIImage(named:"selectBackground_icon"), for: .normal)
        sender.setTitleColor(.white, for: .normal)
    }


  
}
<file_sep>//
//  NSObject+Extension.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/1.
//  Copyright © 2016年 周. All rights reserved.
//

import Foundation

extension NSObject{
    /**
     获取对象对于的属性值，无对于的属性则返回NIL
     
     - parameter property: 要获取值的属性
     
     - returns: 属性的值
     */
    func getValueOfProperty(property:String)->AnyObject?{
        let allPropertys = self.getAllPropertys()
        if(allPropertys.contains(property)){
            return self.value(forKey: property) as AnyObject?
            
        }else{
            return nil
        }
    }
    
    /**
     设置对象属性的值
     
     - parameter property: 属性
     - parameter value:    值
     
     - returns: 是否设置成功
     */
    func setValueOfProperty(property:String,value:AnyObject)->Bool{
        let allPropertys = self.getAllPropertys()
        if(allPropertys.contains(property)){
            self.setValue(value, forKey: property)
            return true
            
        }else{
            return false
        }
    }
    
    /**
     获取对象的所有属性名称
     
     - returns: 属性名称数组
     */
    func getAllPropertys()->[String]{
        
        var result = [String]()
        let count = UnsafeMutablePointer<UInt32>.allocate(capacity: 0)
        let buff = class_copyPropertyList(object_getClass(self), count)
        let countInt = Int(count[0])
        
        for i in 0..<countInt{
            let temp = buff?[i]
            let tempPro = property_getName(temp)
            let proper = String(cString: tempPro!)
            result.append(proper)
            
        }
        
        return result
    }
}
<file_sep>//
//  MainTopTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/18.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
protocol MainTopTableViewCellDelegate :NSObjectProtocol {
    func pushToNewViewController(index:Int)
}
class MainTopTableViewCell: UITableViewCell {

    @IBOutlet weak var view0: UIView!
    @IBOutlet weak var view1: UIView!
    @IBOutlet weak var view2: UIView!
    @IBOutlet weak var view3: UIView!
    weak var delegate :MainTopTableViewCellDelegate!
    override func awakeFromNib() {
        super.awakeFromNib()
        self.view0.tag = 0
        self.view1.tag = 1
        self.view2.tag = 2
        self.view3.tag = 3
        let tap0 = UITapGestureRecognizer(target: self, action: #selector(MainTopTableViewCell.pushAction(_:)))
        let tap1 = UITapGestureRecognizer(target: self, action: #selector(MainTopTableViewCell.pushAction(_:)))
        let tap2 = UITapGestureRecognizer(target: self, action: #selector(MainTopTableViewCell.pushAction(_:)))
        let tap3 = UITapGestureRecognizer(target: self, action: #selector(MainTopTableViewCell.pushAction(_:)))
        self.view0.addGestureRecognizer(tap0)
        self.view1.addGestureRecognizer(tap1)
        self.view2.addGestureRecognizer(tap2)
        self.view3.addGestureRecognizer(tap3)

    }
    func pushAction(_ sender: UITapGestureRecognizer){
       self.delegate.pushToNewViewController(index: (sender.view?.tag)!)
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  MineSecondTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/19.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class MineSecondTableViewCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDataSource {
    let  mineSecondCollectionCellIdentifier = "mineSecondCollectionCell"
    let  imageArray = ["icon_0_0","icon_0_1","icon_0_2","icon_0_3","icon_0_4"]
    let titleArray = ["待付款","待发货","待收货","待评价","退款/售后"]
    
    @IBOutlet weak var collectionView: UICollectionView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        let layout = PublicCollectionViewLayout(sectionInset: UIEdgeInsets.zero, minimumLineSpacing: 0, minimumInteritemSpacing: 0, itemSize: CGSize(width: SCREEN_WIDTH/5, height: 80))
        collectionView.collectionViewLayout = layout
        self.collectionView.dataSource = self
        self.collectionView.delegate = self

        // Initialization code
    }
    //MARK: -- UICollectionViewDataSource

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 5
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: mineSecondCollectionCellIdentifier, for: indexPath) as! MineSecondCollectionViewCell
        cell.imageView.image = UIImage(named: imageArray[indexPath.row])
        cell.titleLabel.text = titleArray[indexPath.row]
        
        return cell
    }
    

    //MARK: -- UICollectionViewDelegate
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        print("点击第\(indexPath.row+1)个")
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  UI.swift
//  SuperWeChat
//
//  Created by 周鹏杰 on 16/8/19.
//  Copyright © 2016年 周. All rights reserved.
//
import UIKit




extension UIViewController{
    //设置导航标题
    func setNavigationTitle(_ title:String?){
         self.navigationItem.title = title

    }
    //添加返回按钮 默认标题为""
    func addBackItem(title:String = ""){
        let backItem = UIBarButtonItem()
        backItem.title = title
        self.navigationController?.navigationBar.tintColor = .black
        let backgroundImage = UIImage(named:"icon_arrow_left")
        let backImage = backgroundImage?.resizableImage(withCapInsets: UIEdgeInsets(top: 0, left: 7, bottom: 0, right: 0))
        backItem.setBackButtonBackgroundImage(backImage, for: .normal, barMetrics: .default)
        backItem.setBackButtonTitlePositionAdjustment(UIOffset(horizontal: 0, vertical: 0), for: .default)
        self.navigationItem.backBarButtonItem = backItem
    }
    //修改右侧导航栏按钮字体大小
    func setRightItem(fontSize:CGFloat){
        let rightItem = self.navigationItem.rightBarButtonItem
        rightItem?.setTitleTextAttributes([NSFontAttributeName: UIFont.systemFont(ofSize: fontSize)], for: .normal)
        self.navigationItem.rightBarButtonItem = rightItem
    }
    func returnAction(_ sender:UIBarButtonItem){
        self.navigationController?.customPopViewController(animated: true)
    }
}
<file_sep>//
//  ClassStoryboardHelper.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/12.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class ClassStoryboardHelper: NSObject {
    
        static let storyboardName = "Class"
        static let navigationController = "classNavigationController"
        static let classViewController = "classViewController"

        class func instantiateViewController( identifier: String) -> UIViewController {
            let storyboard:UIStoryboard!
            storyboard = UIStoryboard(name:self.storyboardName, bundle: nil)
            let viewController = storyboard.instantiateViewController(withIdentifier: identifier)
            return viewController
        }

}
<file_sep>//
//  EditPhoneOneViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/1.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class EditPhoneOneViewController: UIViewController {
    var phoneString:String!
    
    
    @IBOutlet weak var phoneLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addBackItem()
        self.setPhoneLabel()
        
    }
    func setPhoneLabel(){
        if let phoneNumber = phoneString{
            self.phoneLabel.text = phoneNumber
            
        }else{
            self.phoneLabel.text = "该账号未绑定手机"
        }
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    


    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if let vc = segue.destination as? EditPhoneTwoViewController{
            vc.oldPhoneNumber = "15857476747"
        }
    }
    

}
<file_sep>//
//  AppDelegate.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/9.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
import IQKeyboardManagerSwift
import MMDrawerController
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var leftSlideVC: LeftSlideViewController!

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        //开启键盘管理
        IQKeyboardManager.sharedManager().enable = true
        //设置窗口大小和rootVC
        self.window = UIWindow(frame: CGRect(x: 0,y: 0,width: SCREEN_WIDTH,height: SCREEN_HEIGTH))

        let guide = UserDefaults.standard.object(forKey: "guide") as? String
        if guide == nil{
            self.window?.rootViewController = GuideViewController()
        }else{
            let leftViewController = LeftDrawerViewController()
            leftViewController.view.backgroundColor = .white
             let mainViewController = MainTabBarViewController()
             leftSlideVC = LeftSlideViewController(leftView: leftViewController, andMainView:mainViewController)
            leftSlideVC.setPanEnabled(false)
            self.window?.rootViewController =  leftSlideVC
 
        }
        self.window?.makeKeyAndVisible()
        return true
    }
    //MMDrawerController的实现
    //            let drawerViewController = MMDrawerController(center: MainTabBarViewController(), leftDrawerViewController: leftViewController)
    //            drawerViewController?.maximumLeftDrawerWidth = SCREEN_WIDTH*0.5
    //            drawerViewController?.openDrawerGestureModeMask = .all
    //            drawerViewController?.closeDrawerGestureModeMask = .all

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

<file_sep>//
//  GoodsTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/21.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit


class SupportView:UIView{
    var supportView1 = UIImageView()
    var supportView2 = UIImageView()
    var supportView3 = UIImageView()

    var supportLabel1 = UILabel()
    var supportLabel2 = UILabel()
    var supportLabel3 = UILabel()

    
    var moreImageView = UIImageView()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(supportView1)
        self.addSubview(supportView2)
        self.addSubview(supportView3)
        self.addSubview(supportLabel1)
        self.addSubview(supportLabel2)
        self.addSubview(supportLabel3)
        self.addSubview(moreImageView)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setFormat()
    }
    
    func setLayout(){
        supportView1.snp.makeConstraints { (make) in
            make.width.height.equalTo(10)
            make.left.equalToSuperview()
            make.centerY.equalToSuperview()
        }
        supportLabel1.snp.makeConstraints { (make) in
            make.left.equalTo(supportView1.snp.right).offset(5)
            make.centerY.equalToSuperview()
        }
        supportView2.snp.makeConstraints { (make) in
            make.width.height.equalTo(supportView1)
            make.left.equalTo(supportLabel1.snp.right).offset(5)
            make.centerY.equalToSuperview()
        }
        supportLabel2.snp.makeConstraints { (make) in
            make.left.equalTo(supportView2.snp.right).offset(5)
            make.centerY.equalToSuperview()
        }

        supportView3.snp.makeConstraints { (make) in
            make.width.height.equalTo(supportView1)
            make.left.equalTo(supportLabel2.snp.right).offset(5)
            make.centerY.equalToSuperview()
        }
        supportLabel3.snp.makeConstraints { (make) in
            make.left.equalTo(supportView3.snp.right).offset(5)
            make.centerY.equalToSuperview()
        }
        moreImageView.snp.makeConstraints { (make) in
            make.right.equalToSuperview()
            make.centerY.equalToSuperview()
            make.width.equalTo(13)
            make.height.equalTo(3)
        }

    }
    func setData(supportTitleArray:String ...){
        self.supportLabel1.text = supportTitleArray[0]
        self.supportLabel2.text = supportTitleArray[1]
        self.supportLabel3.text = supportTitleArray[2]

    }
    func setFormat(){
        self.supportLabel1.font = SmallFont
        self.supportLabel1.textColor = customGray
        self.supportView1.image = UIImage(named:"icon_tick")
        self.supportLabel2.font = SmallFont
        self.supportLabel2.textColor = customGray
        self.supportView2.image = UIImage(named:"icon_tick")
        self.supportLabel3.font = SmallFont
        self.supportLabel3.textColor = customGray
        self.supportView3.image = UIImage(named:"icon_tick")
        self.moreImageView.image = UIImage(named:"icon_more")
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
class GoodsTableViewCell: UITableViewCell {
    var goodsNameLabel = UILabel()
    let lineView  = UIView()
    var shareButton = UIButton()
    var newPriceLabel = UILabel()
    var oldPriceLabel  = UILabel()
    var freightLabel = UILabel()
    var saleCountLabel  = UILabel()
    var addressLabel = UILabel()
    var supportView = SupportView()

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(goodsNameLabel)
        self.contentView.addSubview(lineView)
        self.contentView.addSubview(shareButton)
        self.contentView.addSubview(newPriceLabel)
        self.contentView.addSubview(oldPriceLabel)
        self.contentView.addSubview(freightLabel)
        self.contentView.addSubview(saleCountLabel)
        self.contentView.addSubview(addressLabel)
        self.contentView.addSubview(supportView)
        self.selectionStyle = .none
        self.setAllAttributes()
       }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFormat()
    }
    
    func setLayout(){
        goodsNameLabel.snp.makeConstraints { (make) in
            make.left.top.equalToSuperview().offset(10)
        }
        shareButton.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-10)
            make.top.equalTo(goodsNameLabel)
            make.width.height.equalTo(14)
        }
        lineView.snp.makeConstraints { (make) in
            make.width.equalTo(1)
            make.height.equalTo(goodsNameLabel)
            make.centerY.equalTo(shareButton)
            make.right.equalTo(shareButton.snp.left).offset(-10)
        }
        newPriceLabel.snp.makeConstraints { (make) in
            make.top.equalTo(goodsNameLabel.snp.bottom).offset(10)
            make.left.equalToSuperview().offset(10)
        }
        oldPriceLabel.snp.makeConstraints { (make) in
            make.bottom.equalTo(newPriceLabel)
            make.left.equalTo(newPriceLabel.snp.right).offset(10)
        }
        freightLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(10)
            make.top.equalTo(newPriceLabel.snp.bottom).offset(5)
        }
        saleCountLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(freightLabel)
        }
        addressLabel.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-10)
            make.top.equalTo(saleCountLabel)
        }
        supportView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.top.equalTo(freightLabel.snp.bottom).offset(20)
            make.width.equalTo(20)
            
        }
        
    }
    func setData(){
        self.goodsNameLabel.text = "白色针织衫"
        self.newPriceLabel.text = "￥100"
        self.oldPriceLabel.text = "￥200"
        self.freightLabel.text = "快递：免运费"
        self.saleCountLabel.text = "月销1200笔"
        self.addressLabel.text = "浙江 宁波"
        self.supportView.setData(supportTitleArray: "7天无理由退货","信用卡支付","蚂蚁花呗")
        
    }
    func setFormat(){
        self.goodsNameLabel.font = MiddleFont
        self.shareButton.setBackgroundImage(UIImage(named:"icon_share"), for: .normal)
        self.lineView.backgroundColor = customGray
        self.newPriceLabel.setNewLabel(headerFontSize:10,footerFontSize: 13)
        self.oldPriceLabel.setOldLabel(fontSize: 10)
        self.freightLabel.font = SmallFont
        self.saleCountLabel.font = SmallFont
        self.addressLabel.font = SmallFont
        self.freightLabel.textColor = customGray
        self.saleCountLabel.textColor = customGray
        self.addressLabel.textColor = customGray


    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  MineHeaderTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/19.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class MineHeaderTableViewCell: UITableViewCell {

    @IBOutlet weak var headerImageView: UIImageView!
    override func awakeFromNib() {
        super.awakeFromNib()
        self.headerImageView.ViewToRoundView(borderWidth: 2.5, borderColor: .white)
    
    
    }


    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  ClassDetailCollectionViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/13.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class ClassDetailCollectionViewCell: UICollectionViewCell {
    
}
<file_sep>platform :ios, '8.0'
use_frameworks!
target 'HiShopping' do
   pod 'Alamofire'
   pod 'SnapKit'
   pod 'SDWebImage'
   pod 'SDCycleScrollView'
   pod 'KNSemiModalViewController'
   pod 'XLPagerTabStrip'
   pod 'Popover'
   pod 'MWPhotoBrowser'
   pod 'IQKeyboardManagerSwift'
   pod 'SwiftyJSON'
   pod 'HandyJSON'
   pod 'MMDrawerController', '~> 0.5.7'
end
<file_sep>//
//  GuideViewController.swift
//  YYT-V3-SalaryEdition
//
//  Created by archer.wang on 15/8/12.
//  Copyright (c) 2015年 Chinajey. All rights reserved.
//

import UIKit


class GuideViewController: UIViewController ,UIScrollViewDelegate{
    
    let kNumberOfScreen = 2
    
    var scrollView:UIScrollView!
    var pageControl:UIPageControl!
    var startBtn:UIButton!
    var image :UIImage!
    var imageStartButton :UIImage!
    var startContentOffsetX = CGFloat()
    var willEndContentOffsetX = CGFloat()
    var endContentOffsetX = CGFloat()
    var imagePath:[String]?
    var imageVersion:String?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGTH))
        self.scrollView.isScrollEnabled = false
        self.scrollView.isPagingEnabled = true
        self.scrollView.showsHorizontalScrollIndicator=false
        self.scrollView.showsVerticalScrollIndicator=false
        self.scrollView.contentSize=CGSize(width: CGFloat(kNumberOfScreen) * SCREEN_WIDTH,  height: SCREEN_HEIGTH)
        self.getOldImage()
        CountDown.startTime(time: 5){ timeout in
            if timeout == 3{
                UIView.animate(withDuration: 1, animations: {
                    self.scrollView.contentOffset = CGPoint(x: SCREEN_WIDTH, y: 0)
                    
                })
            }else if timeout == 0{
                UserDefaults.standard.set("1", forKey: "guide")
                UserDefaults.standard.synchronize()
                (UIApplication.shared.delegate as! AppDelegate).window?.rootViewController =  MainTabBarViewController()
            }
            
        }
        

    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    // MARK: - ScrollView Delegate
    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        self.startContentOffsetX = scrollView.contentOffset.x
    }
    
    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
        self.willEndContentOffsetX = scrollView.contentOffset.x
        if (self.willEndContentOffsetX != 0 && self.startContentOffsetX == CGFloat((kNumberOfScreen - 1) * Int(SCREEN_WIDTH))) && startContentOffsetX == self.willEndContentOffsetX {
            UserDefaults.standard.set("1", forKey: "guide")
            UserDefaults.standard.synchronize()
            (UIApplication.shared.delegate as! AppDelegate).window?.rootViewController =  MainTabBarViewController()
        }
    }
    
    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        let offset = scrollView.contentOffset
        let bounds = scrollView.frame
        self.pageControl.currentPage = Int(offset.x / bounds.size.width)
    }
    
    func getOldImage(){
        for i in 1...kNumberOfScreen {
            if(SCREEN_WIDTH == 640){
                image = UIImage(named: "引导页640(\(i))")
            } else if(SCREEN_WIDTH == 750){
                image = UIImage(named: "引导页750(\(i))")
            } else {
                image = UIImage(named: "引导页1242(\(i))")
            }
            let imageView = UIImageView(image: image)
            imageView.frame = CGRect(x: CGFloat((i-1))*SCREEN_WIDTH, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGTH)
            imageView.contentMode = UIViewContentMode.scaleToFill
            self.scrollView.addSubview(imageView)
            
        }
        self.scrollView.bounces=false
        self.scrollView.delegate=self
        self.view.addSubview(self.scrollView)

        //self.pageControl=UIPageControl(frame: CGRect(x: SCREEN_WIDTH/2-100, y: 0, width: 200, height: 40))
        //self.pageControl.numberOfPages = 2
        //self.pageControl.pageIndicatorTintColor = UIColor.lightGray
        //self.pageControl.currentPageIndicatorTintColor = UIColor.darkGray
        //self.pageControl.currentPage = 0
        //self.view.addSubview(self.pageControl)
    }
    
    override var prefersStatusBarHidden : Bool {
        return true
    }
    
    override var shouldAutorotate : Bool{
        return false
    }
    
}
<file_sep>//
//  MainStoryboardHelper.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/11.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class MainStoryboardHelper: NSObject {
    
    static let storyboardName = "Main"
    static let navigationController = "mainNavigationController"
    static let mainViewController = "mainViewController"
    static let searchViewController = "searchViewController"
    static let pointBuyViewController = "pointBuyViewController"
    static let todayCheapViewController = "todayCheapViewController"
    class func instantiateViewController( identifier: String) -> UIViewController {
        let storyboard:UIStoryboard!
        storyboard = UIStoryboard(name:self.storyboardName, bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: identifier)
        return viewController
    }
}
<file_sep>//
//  LeftDrawerViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/21.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
class LeftDrawerTableViewCell: UITableViewCell {
    var iconImageView = UIImageView()
    var titleLabel = UILabel()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(iconImageView)
        self.contentView.addSubview(titleLabel)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setFrame()
    }
    
    func setLayout(){
        iconImageView.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.height.equalTo(30)
        }
        titleLabel.snp.makeConstraints { (make) in
            make.top.equalTo(iconImageView.snp.bottom).offset(5)
            make.width.equalTo(iconImageView)
            make.left.equalTo(iconImageView)
            
        }
    }
    func setData(image:String,title:String){
        self.iconImageView.image = UIImage(named:image)
        self.titleLabel.text = title
    }
    func setFrame(){
        self.titleLabel.textAlignment = .center
        self.titleLabel.font = BigFont
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
protocol LeftDrawerViewControllerDelegate:NSObjectProtocol {
    func pushViewController(index:Int)
}
class LeftDrawerViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
    let leftCellIdentifier = "leftCell"
    let iconArray:[(image:String,title:String)] = [
        ("icon_home","首页"),
        ("icon_collection_gray_big","收藏"),
        ("icon_message_big","消息"),
        ("icon_position","发现"),
        ("icon_set","设置")
    ]
   weak var delegate : LeftDrawerViewControllerDelegate!
   var tableView = UITableView()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setTableView()
    }
    private  func setTableView(){
        self.view.addSubview(tableView)
        self.tableView.frame = self.view.bounds
        tableView.separatorStyle = .none
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(LeftDrawerTableViewCell.self, forCellReuseIdentifier: leftCellIdentifier)
    }
    //MARK:- UITableViewDataSource
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell =  tableView.dequeueReusableCell(withIdentifier: leftCellIdentifier, for: indexPath) as! LeftDrawerTableViewCell
        if  indexPath.row%2 != 0{
            cell.contentView.backgroundColor = HiTaoBackgroundColor
        }
        cell.setData(image: iconArray[indexPath.row].image, title:  iconArray[indexPath.row].title)
        return cell
    }
    //MARK:-UITableViewDelegate
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return SCREEN_HEIGTH/5
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        switch indexPath.row {
        case 3:
            let appDelegate = UIApplication.shared.delegate as! AppDelegate
            appDelegate.leftSlideVC.closeLeftView()
            let brandViewController = BrandViewController()
            brandViewController.hidesBottomBarWhenPushed = true
            let mainTabBarViewController = appDelegate.leftSlideVC.mainVC as! MainTabBarViewController
            (mainTabBarViewController.viewControllers?[mainTabBarViewController.selectedIndex] as! UINavigationController).pushViewController(brandViewController, animated: true)
            
        default:
            print("侧边栏点击事件")
        }
    }

    

  
}
<file_sep>//
//  ColorTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/24.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class SpecTableViewCell: UITableViewCell {
    var contentLabel = UILabel()
    var selectImageView = UIImageView()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(selectImageView)
        self.contentView.addSubview(contentLabel)
        self.setAllAttributes()
        
    }
    func setAllAttributes(){
        self.setLayout()
        self.setFormat()
    }
    
    func setLayout(){
        contentLabel.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
        }
    }
    //根据文本内容控制ImageView的大小
    override func layoutIfNeeded() {
        super.layoutIfNeeded()
        self.selectImageView.frame = CGRect(x: contentLabel.frame.origin.x - 5, y:  contentLabel.frame.origin.y - 5 , width: contentLabel.frame.size.width + 10, height: contentLabel.frame.size.height + 10)
    }
    //设置文本控件的内容和颜色
    func setData(textString:String){
        self.contentLabel.text = textString
        self.contentLabel.textColor = customGray
        
    }
    func setFormat(){
        contentLabel.textAlignment = .center
        contentLabel.font = MiddleFont
        contentLabel.textColor = customGray
        selectImageView.image = UIImage(named:"line_51x51")
        selectImageView.isHidden = true
       
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  WaterFlowTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/11.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class WaterFlowTableViewCell: UITableViewCell,UICollectionViewDataSource {
    let layout = WaterFlowViewLayout()
    let ReuseIdentifier = "cell"
    @IBOutlet weak var waterFlowView: UICollectionView!
    override func awakeFromNib() {
        super.awakeFromNib()
        waterFlowView.dataSource = self
        self.waterFlowView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: ReuseIdentifier)
        layout.columnCount = 3
        layout.columnMargin = 10.5
        layout.rowMargin = 10
        layout.sectionInsert = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
        layout.itemHeightBlock = {(a,b) in
            return CGFloat(80 + arc4random_uniform(50))
        }
        waterFlowView.collectionViewLayout = layout

    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        return 100
    }

    open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ReuseIdentifier, for: indexPath)
        cell.backgroundColor = UIColor.randomColor()
        return cell
    }

}
<file_sep>//
//  DetailsStoryboardHelper.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/2.
//  Copyright © 2016年 周. All rights reserved.
//

import Foundation
class DetailsStoryboardHelper: NSObject {
    
    static let storyboardName = "Details"
    static let navigationController = "classNavigationController"
    static let confirmOrderViewController = "confirmOrderViewController"
    
    class func instantiateViewController( identifier: String) -> UIViewController {
        let storyboard:UIStoryboard!
        storyboard = UIStoryboard(name:self.storyboardName, bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: identifier)
        return viewController
    }
    
}
<file_sep>//
//  MineOrderChildViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/20.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
import XLPagerTabStrip
class MineOrderChildViewController: UIViewController , IndicatorInfoProvider ,UITableViewDataSource,UITableViewDelegate{
    var index:Int!
    let mineOrderCellIdentifier = "mineOrderCell"
    let mineOrdeBottomCellIdentifier = "mineOrderBottomCell"
    var itemInfo : IndicatorInfo!
    var tableView = UITableView(frame: CGRect.zero, style: .grouped)
    var orderCountArray = [3,4,5,6,2,3,5,6,2,3]
    init(itemInfo: IndicatorInfo,index:Int) {
        self.itemInfo = itemInfo
        self.index = index
        super.init(nibName: nil, bundle: nil)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.addSubview(tableView)
        self.setTableView()
    }
    private func setTableView(){
        tableView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.register(MineOrderProductTableViewCell.self, forCellReuseIdentifier: mineOrderCellIdentifier)
        self.tableView.register(MineOrderBottomTableViewCell.self, forCellReuseIdentifier: mineOrdeBottomCellIdentifier)
        self.tableView.separatorStyle = .none
        self.tableView.backgroundColor = HiTaoBackgroundColor
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    // MARK: - UITableViewDataSource
    func numberOfSections(in tableView: UITableView) -> Int {
        return 10
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return   orderCountArray[section] + 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell: UITableViewCell
        //最后一条返回不同的布局
        if indexPath.row == orderCountArray[indexPath.section]{
            cell = tableView.dequeueReusableCell(withIdentifier: mineOrdeBottomCellIdentifier, for: indexPath)
        }else{
             cell = tableView.dequeueReusableCell(withIdentifier: mineOrderCellIdentifier, for: indexPath)
        }
        return cell
    }
    //MARK: - UITableViewDelegate
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
    {
        if indexPath.row == orderCountArray[indexPath.section]{
            return 50

        }else{
            return 80
        }
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        switch section {
        case 0:
            return 1
            
        default:
            return 0.0001
        }
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
      return 10
    }

    // MARK: - IndicatorInfoProvider
    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return itemInfo
    }



}
<file_sep>//
//  MineCollectionViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/23.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class MineCollectionViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource {
    let collectionCellIdentifier = "collectionCell"
    var dataArray:[Bool] = [true,true,false,true,false,true,false,true,true,true]
    var collectionView:UICollectionView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setCollectionView()
    }
    private func setCollectionView(){
        let layout = WaterFlowViewLayout()
        layout.columnCount = 2
        layout.columnMargin = 10
        layout.rowMargin = 10
        layout.sectionInsert = UIEdgeInsets(top: 0, left: 10, bottom: 10, right: 10)
        //判断是否有标签栏
        layout.itemHeightBlock = {[weak self](itemWitdh,indexPath) in
            return  (self?.dataArray[indexPath.row])! ? (SCREEN_WIDTH-30)/2 + 80 : (SCREEN_WIDTH-30)/2 + 50
        }
        self.collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout:layout)
        self.collectionView.backgroundColor = HiTaoBackgroundColor
        self.collectionView.delegate = self
        self.collectionView.dataSource = self
        self.view.addSubview(collectionView)
        self.collectionView.backgroundColor = HiTaoBackgroundColor
        collectionView.snp.makeConstraints { (make) in
            make.left.right.top.bottom.equalToSuperview()
            
        }
        self.collectionView.register(MineCollectionCollViewCell.self, forCellWithReuseIdentifier: collectionCellIdentifier)
        
    }
    //UICollectionViewDataSource
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 10
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: collectionCellIdentifier, for: indexPath) as! MineCollectionCollViewCell
        cell.setData(isBtnHaving: dataArray[indexPath.row])
        return cell
    }

}
<file_sep>//
//  SearchViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/25.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class SearchViewController: UIViewController,UITableViewDataSource ,UITableViewDelegate,UITextFieldDelegate,HJTextFieldDelegate,SearchTableViewCellDelegate{
    //是否开始搜索
    var  isStartSearch :Bool = false{
        willSet{
            self.topView.isHidden = newValue
            if newValue{
                self.tableView.frame.origin.y = naviStateBarHeight
                
            }else{
                //40为topView高度
                self.tableView.frame.origin.y = 40 + naviStateBarHeight
            }
        }
    }
    //条件1的值去改变Button的高度
    //条件1选择的值
    var firstCondition:Int!{
        //添加属性观察者
        didSet{
            //判断是否已有选择
            if let oldValue = oldValue{
                changeOldButtonHeight(tag: oldValue)

            }
        }
        willSet{
            changeNewButtonHeight(tag: newValue)
        }
    }



    //搜索记录数组
    var  historyArray  = ["新品发布","热销排行","本周排行","整","新品发布","热销排行","本周排行","整"]
    //标签数组
    var  iconArray  = ["新品发布","热销排行","本周排行","整","新品发布","热销排行","本周排行","整"]
    //搜索结果数组
    var searchArray = ["新品发布","热销排行","本周排行","整","新品发布","热销排行","本周排行","整"]
    @IBOutlet weak var searchTextField: HJTextField!
    @IBOutlet weak var topView: UIView!
    @IBOutlet weak var tableView: UITableView!
    var iconCellHeight:CGFloat = 0
    var historyCellHeight:CGFloat = 0
    let searchIconCellIdentifier = "searchIconCell"
    let searchHistoryCellIdentifier = "searchHistoryCell"
    let searchResultCellIdentifier = "searchResultCell"
    override func viewDidLoad() {
        super.viewDidLoad()
        //指定输入框代理
        self.searchTextField.delegate = self
        self.searchTextField.HJDelegate = self
        self.searchTextField.addTarget(self, action: #selector(SearchViewController.textFieldValueChange(_:)), for: .editingChanged)
        //搜索框圆角设置
        self.searchTextField.ViewToRoundViewBycornerRadius(cornerRadius: 5)
    }
 

    @IBAction func selectFirstCondition(_ sender: UIButton) {
        self.firstCondition = sender.tag
    }
    //以前选择的Button高度增大
    func changeOldButtonHeight(tag:Int){
        for view in topView.subviews {
            if view.tag == tag{
                view.frame.size.height += 1
            }
        }
    }
    //当前选择的Button高度增大
    func changeNewButtonHeight(tag:Int){
        for view in topView.subviews {
            if view.tag == tag{
                view.frame.size.height -= 1
            }
        }
    }
    override func viewWillAppear(_ animated: Bool) {
        //隐藏tabBar
        self.navigationController?.navigationBar.isTranslucent = true
        
    }
    override func viewWillDisappear(_ animated: Bool) {
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //MARK:- UITableViewDataSource
    func numberOfSections(in tableView: UITableView) -> Int {
        return  isStartSearch ? searchArray.count :  2
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        //如果开始搜索显示搜索的cell
        if isStartSearch{
            let cell = tableView.dequeueReusableCell(withIdentifier: searchResultCellIdentifier, for: indexPath)
            return cell
        }
        switch indexPath.section {
        case 0:
            let cell = tableView.dequeueReusableCell(withIdentifier: searchIconCellIdentifier, for: indexPath) as! SearchIconTableViewCell
            cell.iconArray = self.iconArray
            cell.addButton()
            //30button高度 20分别为垂直方向上下间距
            iconCellHeight = cell.topSpace + 30 + 20
            return cell
        default:
            let cell = tableView.dequeueReusableCell(withIdentifier: searchHistoryCellIdentifier, for: indexPath) as! SearchHistoryTableViewCell
            cell.historyArray = self.historyArray
            cell.addButton()
            historyCellHeight = cell.topSpace + 30 + 20 
            cell.delegate = self
            return cell
        }

        
    }
    //MARK:- UITableViewDelegate
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if isStartSearch{
            let vc = SearchResultViewController()
            vc.hidesBottomBarWhenPushed = true
           self.navigationController?.pushViewController(vc, animated: true)
        }
    }
    
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        //如果开始搜索返回搜索的cell的高度
        if isStartSearch{
            return 50
        }

        switch indexPath.section {
        case 0:
            return iconCellHeight
        default:
            //64导航栏和状态栏 40条件1的高度  1tableviewHeader Section == 0的高度 10tableviewHeader Section == 1的高度
            return SCREEN_HEIGTH - 64 - 40 - 1 - iconCellHeight - 10
        }
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        if isStartSearch{
            return 1
        }
        switch section {
        case 0:
            return 1

        default:
            return 10
        }
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.00001
    }

    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        //判断是否是第一个控制view的高度
        let height:CGFloat = section == 0 || isStartSearch ? 1 : 10
        let view = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: height))
        view.backgroundColor = HiTaoBackgroundColor
        return view
    }
    
    //MARK:- UITextFieldDelegate
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        let contentString : String = textField.text!
        let newRange = range.toRangeByString(content: contentString)
        //搜索内容
        let string = contentString.replacingCharacters(in: newRange , with: string)
        print(string)
        return true
    }
    

    //MARK:- SearchTableViewCellDelegate
    
    /// 实现删除操作的代理方法
    func deleteHistoryInSearch() {
        //清空历史搜索记录数组
        self.historyArray.removeAll(keepingCapacity: true)
        //指定刷新cell
        self.tableView.reloadRows(at: [IndexPath(row: 0, section: 1)], with: .automatic)
    }

    //设置textField右图为扫一扫
    func setTextFieldRightScaningView(){
        let rightView = UIButton(frame: CGRect(x: 0, y: 0, width:self.searchTextField.frame.height*0.5, height:  self.searchTextField.frame.height*0.5))
        rightView.setImage(UIImage(named:"scanning_icon"), for: .normal)
        rightView.addTarget(self, action: #selector(SearchViewController.scanningTextField(_:)), for:.touchUpInside)
        self.searchTextField.rightView = rightView
    }
    //设置textField右图为清空
    func setTextFieldRightClearView(){
        let rightView = UIButton(frame: CGRect(x: 0, y: 0, width:self.searchTextField.frame.height*0.5, height:  self.searchTextField.frame.height*0.5))
        rightView.setImage(UIImage(named:"clear_icon"), for: .normal)
        rightView.addTarget(self, action: #selector(SearchViewController.clearTextField(_:)), for:.touchUpInside)
        self.searchTextField.rightView = rightView
    }
    func textFieldValueChange(_ sender: UITextField){
        if (sender.text?.characters.count)! > 0{
            isStartSearch = true
            self.setTextFieldRightClearView()
        }else{
            isStartSearch = false
            self.setTextFieldRightScaningView()
        }
        self.tableView.reloadData()
    }
    //清空输入
    func clearTextField(_ sender:UIButton){
        self.searchTextField.text = ""
        isStartSearch = false
        self.setTextFieldRightScaningView()
        self.tableView.reloadData()
        
    }
    func scanningTextField(_ sender:AnyObject?){
          print("start scanning")
        
    }
    
    
    
    

}
<file_sep>//
//  ConfirmOrderViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/2.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class ConfirmOrderViewController: UIViewController,UITableViewDataSource ,UITableViewDelegate{
   let addressCellIdentifier = "addressCell"
    let goodsCellIdentifier = "goodsCell"
    let moreCellIdentifier = "moreCell"
    let discountCellIdentifier = "discountCell"
    let priceCellIdentifier = "priceCell"
    let payModeHeaderCellIdentifier = "payModeHeaderCell"
    let payModeCellIdentifier = "payModeCell"
    let payModelHeaderIdentifier = "payModeHeader"
    var isOpenPayMode = false
    var payModeCode  :Int! = 0
    @IBOutlet weak var tableView: UITableView!
    

    override func viewDidLoad() {
        super.viewDidLoad()
        self.tableView.register(PayModeHeaderView.self, forHeaderFooterViewReuseIdentifier: payModelHeaderIdentifier)
    }
    

    
 
    @IBAction func confirmPay(_ sender:UIButton){
        print("确认支付")
       
    }
    //MARK:- UITableViewDataSource
    func numberOfSections(in tableView: UITableView) -> Int {
        return 5
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        switch section {
        case 0:
            return 1
        case 1:
            return 3
        case 2:
            return 1
        case 3:
            return 1
        default:
            return isOpenPayMode ? 3 : 1
        }
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        switch indexPath.section {
        case 0:
            let cell = tableView.dequeueReusableCell(withIdentifier: addressCellIdentifier, for: indexPath)
            return cell
        case 1:
            switch indexPath.row {
            case 0...1:
                let cell = tableView.dequeueReusableCell(withIdentifier: goodsCellIdentifier, for: indexPath)
                return cell
            default:
                let cell = tableView.dequeueReusableCell(withIdentifier: moreCellIdentifier, for: indexPath)
                return cell

            }
        case 2:
            let cell = tableView.dequeueReusableCell(withIdentifier: discountCellIdentifier, for: indexPath)
            return cell
        case 3:
            let cell  = tableView.dequeueReusableCell(withIdentifier: priceCellIdentifier, for: indexPath)
            return cell
            
        default:
            switch indexPath.row {
            case 0:
                let cell = tableView.dequeueReusableCell(withIdentifier: payModeHeaderCellIdentifier, for: indexPath) as! PayModeHeaderTableViewCell
                return cell
            default: 
                let cell = tableView.dequeueReusableCell(withIdentifier: payModeCellIdentifier, for: indexPath) as! PayModeTableViewCell
                if payModeCode == indexPath.row{
                    cell.selectImageView.image = #imageLiteral(resourceName: "roundSelect")
                }else{
                    cell.selectImageView.image = #imageLiteral(resourceName: "roundUnSelect")
                }
                return cell
            }
        }
    }

    //MARK:- UITableViewDelegate
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        switch indexPath.section {
        case 0:
            return 80
        case 1:
            switch indexPath.row {
            case 0...1:
                return 100
            default:
                return 50
            }
        case 2:
            return 50
        case 3:
            return 85
        default:
            return 50
        }
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        switch section {
        case 0:
            return 1
        case 1...3:
            
            return 10
        default:
            return 5
        }
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.000001
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.section == 4{
            if indexPath.row == 0{
                let cell = tableView.cellForRow(at: indexPath) as! PayModeHeaderTableViewCell
                self.isOpenPayMode = !self.isOpenPayMode
                UIView.animate(withDuration: 0.3, animations: {
                    if self.isOpenPayMode{
                        tableView.insertRows(at: [IndexPath(row: 1, section: 4),IndexPath(row: 2, section: 4)], with: .automatic)
                        tableView.setContentOffset(CGPoint(x: 0, y: 100), animated: true)
                        
                    }else{
                        tableView.deleteRows(at:  [IndexPath(row: 1, section: 4),IndexPath(row: 2, section: 4)], with: .automatic)
                    }
                    let transform = cell.isOpenImageView.transform.rotated(by: CGFloat(M_PI))
                    cell.isOpenImageView.transform = transform

                }, completion: nil)
            }else{
                self.payModeCode = indexPath.row
                self.tableView.reloadRows(at: [IndexPath(row: 1, section: 4),IndexPath(row: 2, section: 4)], with: .automatic)
            }
        }
        
    }
   

}
<file_sep>//
//  HJTextField.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/25.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
protocol HJTextFieldDelegate:NSObjectProtocol {
    func scanningTextField(_ sender:AnyObject?)
}
@IBDesignable
class HJTextField: UITextField {
    
    weak var HJDelegate :HJTextFieldDelegate!
    override func awakeFromNib() {
        let rightTap = UITapGestureRecognizer(target: self, action: #selector(HJTextField.scanning(_:)))
        self.rightView?.addGestureRecognizer(rightTap)
        
        
    }
    func scanning(_ tap :UITapGestureRecognizer){
        HJDelegate.scanningTextField(tap.view)
    }
    @IBInspectable var leftImage: UIImage? {
        set {
            let leftImgView = UIButton()
            leftImgView.setImage(newValue, for: .normal)
            leftImgView.frame = CGRect(x: frame.height*0.1,
                                       y: frame.height*0.1,
                                       width: frame.height*0.5,
                                       height: frame.height*0.5)
            leftView = leftImgView
            leftViewMode = .always
        }
        
        get {
            if let leftImgView = leftView as? UIButton {
                return leftImgView.image(for: .normal)
            }
            return nil
        }
        
        
    }
    @IBInspectable var rightImage: UIImage? {
        set {
            let rightImgView = UIButton()
            rightImgView.setImage(newValue, for: .normal)
            rightImgView.frame = CGRect(x: frame.height*0.1,
                                       y: frame.height*0.1,
                                       width: frame.height*0.5,
                                       height: frame.height*0.5)
            rightView = rightImgView
            rightViewMode = .always
        }
        
        get {
            if let rightImgView = rightView as? UIButton {
                return rightImgView.image(for: .normal)
            }
            return nil
        }
    }
    
    override func leftViewRect(forBounds bounds: CGRect) -> CGRect {
        var rect = super.leftViewRect(forBounds: bounds)
        rect = CGRect(x: rect.origin.x+10, y: rect.origin.y, width: rect.size.width, height:  rect.size.height)
        return rect
        
    }
    
    override func rightViewRect(forBounds bounds: CGRect) -> CGRect {
        var rect = super.rightViewRect(forBounds: bounds)
        rect = CGRect(x: rect.origin.x-10, y: rect.origin.y, width: rect.size.width, height:  rect.size.height)
        return rect
    }
    



}

<file_sep>//
//  ClassViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/12.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class AllClassViewController: UIViewController,UICollectionViewDataSource,UICollectionViewDelegate {

    @IBOutlet weak var collectionView: UICollectionView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addBackItem()
        self.setCollectionLayout()
        //注册单元
        self.collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "cell")
    }
    override func viewWillAppear(_ animated: Bool) {
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        appDelegate.leftSlideVC.setPanEnabled(true)
    }
    override func viewWillDisappear(_ animated: Bool) {
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        appDelegate.leftSlideVC.setPanEnabled(false)
    }
    //设置collectionView
    private func setCollectionLayout(){
        let sectionInset = UIEdgeInsets(top: 0, left: 10, bottom: 10, right: 10)
        let minimumLineSpacing :CGFloat = 0.0
        let minimumInteritemSpacing:CGFloat = 0.0
        let itemSize = CGSize(width: (SCREEN_WIDTH-20)/2, height: (SCREEN_WIDTH-20)/2*(5.0/6.0))
        let layout = PublicCollectionViewLayout(sectionInset: sectionInset, minimumLineSpacing: minimumLineSpacing, minimumInteritemSpacing: minimumInteritemSpacing, itemSize: itemSize)
        self.collectionView.collectionViewLayout = layout
    }

  
    //MARK:- UICollectionViewDataSource
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        return 10
    }
    

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as! ClassCollectionViewCell
        if [0,3].contains(indexPath.row%4) {
            cell.backgroundColor = UIColor.hexStringToColor("f5f2f1")
            
        }else{
             cell.backgroundColor = UIColor.hexStringToColor("ffffff")
        }
        cell.imageView.image = UIImage(named:classImageArray[indexPath.row])
        cell.titleLabel.text = classTitleArray[indexPath.row]
        return cell
    }
    //MARK:- UICollectionViewDelegate
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath){
        let vc = ClassStoryboardHelper.instantiateViewController(identifier: ClassStoryboardHelper.classViewController)
        vc.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(vc, animated: true)
    }
    

    

   
}
<file_sep>//
//  ResultCollectionViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/26.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class ResultCollectionViewCell: UICollectionViewCell {
    var isCollection = false
    var starCount = 888
    var goodsImageView = UIImageView()
    var goodsNameLabel = UILabel()
    var priceLabel = UILabel()
    var starButton = UIButton()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.backgroundColor = .white
        self.contentView.addSubview(goodsImageView)
        self.contentView.addSubview(goodsNameLabel)
        self.contentView.addSubview(priceLabel)
        self.contentView.addSubview(starButton)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFormat()
    }
    
    func setLayout(){
        goodsImageView.snp.makeConstraints { (make) in
            make.width.equalToSuperview()
            make.height.equalTo(goodsImageView.snp.width)
            make.left.top.equalToSuperview()
        }
        goodsNameLabel.snp.makeConstraints { (make) in
            make.left.equalTo(goodsImageView).offset(10)
            make.top.equalTo(goodsImageView.snp.bottom).offset(10)
            make.height.equalTo(11)
        }
        priceLabel.snp.makeConstraints { (make) in
            make.left.equalTo(goodsNameLabel)
            make.top.equalTo(goodsNameLabel.snp.bottom).offset(10)
        }
        starButton.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-10)
            make.centerY.equalTo(priceLabel)
        }
    }
    func setData(){
        self.goodsImageView.image = UIImage(named:imageDefaultName)
        self.goodsNameLabel.text = "ML时尚鸭舌帽"
        self.priceLabel.text = "￥120"
        self.starButton.setTitle("\(starCount)", for: .normal)
    
        
    }
    func setFormat(){
        self.goodsNameLabel.setFontAndTextColor(font: MiddleFont, textColor: UIColor.black)
        self.priceLabel.setFontAndTextColor(font: MiddleFont, textColor: customRed)
        self.starButton.titleLabel?.font = MiddleFont
        self.starButton.setImage(UIImage(named:"unCollect_icon"), for: .normal)
        self.starButton.setTitleColor(customGray, for: .normal)
        self.starButton.addTarget(self, action: #selector(ResultCollectionViewCell.collectGoods(_:)),for: .touchUpInside)
    }
    func collectGoods(_ sender: UIButton) {
        isCollection = !isCollection
        if isCollection{
            starCount += 1
            self.starButton.setImage(UIImage(named:"collect_icon"), for: .normal)
            self.starButton.setTitleColor(customRed, for: .normal)
            self.starButton.setTitle("\(starCount)", for: .normal)
        }else{
            starCount -= 1
            self.starButton.setImage(UIImage(named:"unCollect_icon"), for: .normal)
            self.starButton.setTitleColor(customGray, for: .normal)
            self.starButton.setTitle("\(starCount)", for: .normal)

 
        }
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
<file_sep>//
//  CountDownCollectionHeaderView.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/27.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class CountDownCollectionHeaderView: UICollectionReusableView {
    var timeSeconds = 10000
    var messageLabel = UILabel()
    var  timeLabel = UILabel()
    var leftLineView = UIView()
    var rightLineView = UIView()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(messageLabel)
        self.addSubview(timeLabel)
        self.addSubview(leftLineView)
        self.addSubview(rightLineView)
        self.setAllAttributes()
        
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFormat()
    }
    
    func setLayout(){
        messageLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(10)
        }
        timeLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(messageLabel.snp.bottom).offset(7.5)
        }
    }
    func setData(){
        CountDown.startTime(time: timeSeconds) { (timeout) in
            self.setTime(timeout: timeout)
        }
    }
    func setFormat(){
        self.messageLabel.text = "距离结束还剩"
        self.messageLabel.setFontAndTextColor(font: SmallFont, textColor: customGray)
        self.timeLabel.setFontAndTextColor(font: SmallFont, textColor: .black)
    }
    
    
    /// 设置时间
    ///
    /// - parameter timeout: 剩余倒计时秒数
    func setTime(timeout:Int)  {
        let timeClock = TimeHelper.getTimeOnClock(second: timeout)
        self.timeLabel.text = "\(timeClock.hour):\(timeClock.minute):\(timeClock.second)"
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
   
}
<file_sep>//
//  NewReleaseTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/18.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class NewReleaseTableViewCell: UITableViewCell {
    //计算第一次拉伸的宽度:第一次拉伸宽度=最终宽度/2+原图宽度/2
    let tempWidth = Int((SCREEN_WIDTH*5/8)/2 + 200/2)
    var bgImageView = UIImageView()
    var centerImageView = UIImageView()
    var typeLabel = UILabel()
    var nameLabel = UILabel()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(bgImageView)
        self.contentView.addSubview(centerImageView)
        self.centerImageView.addSubview(typeLabel)
        self.centerImageView.addSubview(nameLabel)
        self.setAllAttributes()

    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFrame()
    }
    
    func setLayout(){
        bgImageView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        centerImageView.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.equalTo(tempWidth)
            make.height.equalTo(40)
        }
        typeLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalTo(self.centerImageView.snp.bottom).offset(-10)
        }
        nameLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalTo(self.centerImageView.snp.top).offset(10)
        }
    }
    func setData(){
        self.bgImageView.image = UIImage(named:imageDefaultName)
        self.typeLabel.text = "美食特产"
        self.nameLabel.text = "鲜花饼"
        
    }
    func setFrame(){
        let bgImage = UIImage(named:"content_img_bg")
        self.centerImageView.image = self.scaleImageView(firstImage: bgImage!)
        self.typeLabel.font = SmallFont
        self.nameLabel.font = BigFont
    }
    func scaleImageView(firstImage:UIImage)-> UIImage{
        //第一次拉伸图片
       let firstScaleImage = firstImage.stretchableImage(withLeftCapWidth:Int(firstImage.size.width * 0.8) , topCapHeight: Int(firstImage.size.height * 0.5))
        UIGraphicsBeginImageContextWithOptions(CGSize(width: self.tempWidth, height: 40), false, UIScreen.main.scale)
        //如果tempWidth没有取整的话就是217.1875 会造成一条竖线的存在 小数值越接近0.5线越细
        //根据猜测应该是屏幕最少显示为1个像素也就是0.5 不足0.5可能会造成绘制图形不足造成空白也就是所谓的竖线 所以这里的处理方式是一律取整从而避免这个问题
        firstScaleImage.draw(in:CGRect(x: 0, y:0 , width: self.tempWidth , height: 40) , blendMode: .normal, alpha: 1)
        let secondImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()
        //重写布局
        centerImageView.snp.remakeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.equalTo(Int(SCREEN_WIDTH*5/8))
            make.height.equalTo(40)
        }
        //第二次拉伸图片
        let secondScaleImage = secondImage.stretchableImage(withLeftCapWidth:Int(secondImage.size.width * 0.2) , topCapHeight: Int(secondImage.size.height * 0.5))
        return secondScaleImage
    }
//另一种拉伸的写法
//      let firstScaleImage = firstImage.resizableImage(withCapInsets: UIEdgeInsets(top: firstImage.size.height * 0.5, left: firstImage.size.width * 0.1, bottom: firstImage.size.height * 0.5-1, right: firstImage.size.width * 0.9-1) )
//       let secondScaleImage = secondImage.resizableImage(withCapInsets: UIEdgeInsets(top: secondImage.size.height * 0.5, left: secondImage.size.width * 0.9-1, bottom: secondImage.size.height * 0.5-1, right: secondImage.size.width * 0.1 ))
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  EvaluateTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/12/10.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class EvaluateTableViewCell: UITableViewCell {
    var headerImageView = UIImageView()
    var userNameLabel = UILabel()
    var dateLabel = UILabel()
    var contentLabel = UILabel()
    var sizeLabel = UILabel()
    var colorLabel = UILabel()
    var starButton = UIButton()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(headerImageView)
        self.contentView.addSubview(userNameLabel)
        self.contentView.addSubview(dateLabel)
        self.contentView.addSubview(contentLabel)
        self.contentView.addSubview(sizeLabel)
        self.contentView.addSubview(colorLabel)
        self.contentView.addSubview(starButton)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFrame()
    }
    
    func setLayout(){
        headerImageView.snp.makeConstraints { (make) in
            make.width.height.equalTo(20)
            make.left.top.equalTo(15)
        }
        userNameLabel.snp.makeConstraints { (make) in
            make.left.equalTo(headerImageView.snp.right).offset(7.5)
            make.centerY.equalTo(headerImageView)
        }
        dateLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(headerImageView)
            make.right.equalToSuperview().offset(-10)
        }
        contentLabel.snp.makeConstraints { (make) in
            make.left.equalTo(headerImageView)
            make.top.equalTo(headerImageView.snp.bottom).offset(10)
        }
        sizeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(headerImageView)
            make.top.equalTo(contentLabel.snp.bottom).offset(10)
        }
        colorLabel.snp.makeConstraints { (make) in
            make.left.equalTo(sizeLabel.snp.right).offset(10)
            make.centerY.equalTo(sizeLabel)
        }
        starButton.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-10)
            make.centerY.equalTo(sizeLabel)
        }
    }
    func setData(){
        self.headerImageView.image = UIImage(named:imageDefaultName)
        self.userNameLabel.text = "设计师是逗逼"
        self.dateLabel.text = "2011-11-11"
        self.contentLabel.text = "对面的女孩看过来看过来"
        self.sizeLabel.text = "尺寸:M"
        self.colorLabel.text = "颜色:白色"
        self.starButton.setTitle("22".toMinLengthString(minLength: 3), for: .normal)
    }
    func setFrame(){
        //更新约束获取frame 方便切圆
        self.layoutIfNeeded()
        self.headerImageView.ViewToRoundView()
        self.userNameLabel.setFontAndTextColor(font: SmallFont, textColor: customGray)
        self.dateLabel.setFontAndTextColor(font: SmallFont, textColor: customGray)
        self.contentLabel.font = MiddleFont
        self.sizeLabel.setFontAndTextColor(font: SmallFont, textColor: customGray)
        self.colorLabel.setFontAndTextColor(font: SmallFont, textColor: customGray)
        self.starButton.setTitleColor(customGray, for: .normal)
        self.starButton.titleLabel?.font = SmallFont
        self.starButton.setImage(UIImage(named:"icon_like"), for: .normal)
        self.starButton.contentHorizontalAlignment = .right
        self.starButton.imageEdgeInsets.right = 5
        starButton.snp.makeConstraints { (make) in
            make.width.equalTo(self.starButton.frame.width + 5)
        }
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
<file_sep>//
//  SearchHistoryTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/25.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
protocol SearchTableViewCellDelegate:NSObjectProtocol {
    func deleteHistoryInSearch()
}
class SearchHistoryTableViewCell: UITableViewCell {
    
    var  historyArray :[String] = []
    let buttonHeight:CGFloat = 30
    let buttonVerticalSpace:CGFloat = 20
    let buttonHorizontalSpace:CGFloat = 20
    var buttonWidthArray :[CGFloat] = []
    var leftStartSpace :CGFloat = 10
    var topSpace:CGFloat = 50
    weak var delegate :SearchTableViewCellDelegate!
    
    @IBAction func deleteAction(_ sender: UIButton) {
        self.delegate.deleteHistoryInSearch()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.addButton()
    }

    func addButton(){
        //恢复初始值
        leftStartSpace  = 10
        topSpace = 50
        //每次刷新需要清除Button避免复用 暂时想不到更好的办法
        for view in self.contentView.subviews{
            if let view = view as? UIButton{
                //删除Button在storyboard中tag值是100作为条件不做remove处理
                guard view.tag == 100 else {
                    view.removeFromSuperview()
                    continue
                }
            }
        }
        //先清空宽度数组
        buttonWidthArray.removeAll(keepingCapacity: true)
        for index in 0..<historyArray.count {
            //每次获取起始左边距离
            var leftSpace = leftStartSpace
            for buttonWidth in buttonWidthArray {
                leftSpace += buttonWidth + buttonHorizontalSpace
            }
            //根据内容和字体大小计算button宽度
            let width = historyArray[index].getStringWidth(font: MiddleFont) + 30
            if leftSpace + buttonHorizontalSpace + width + 10 > SCREEN_WIDTH{
                //换行清空宽度数组
                buttonWidthArray.removeAll(keepingCapacity: true)
                topSpace += buttonVerticalSpace + buttonHeight
                leftStartSpace = 10
                leftSpace = leftStartSpace
            }
            let historyButton = UIButton()
            historyButton.titleLabel?.font = MiddleFont
            historyButton.setTitle(historyArray[index], for: .normal)
            historyButton.setTitleColor(customGray, for: .normal)
            historyButton.setBackgroundImage(UIImage(named:"background_icon"), for: .normal)
            historyButton.tag = index
            self.contentView.addSubview(historyButton)
            historyButton.addTarget(self, action: #selector(SearchIconTableViewCell.selectFirstCondition(_:)), for: .touchUpInside)
            buttonWidthArray.append(width)
            historyButton.snp.makeConstraints({ (make) in
                make.width.equalTo(width)
                make.height.equalTo(buttonHeight)
                make.left.equalTo(leftSpace)
                make.top.equalTo(topSpace)
            })
            
        }
    }
    func selectFirstCondition(_ sender:UIButton){
        switch sender.tag {
        case 0:
            print("选中条件1")
            self.changeButtonColor(sender: sender)
        default:
            print("选中其他条件")
            self.changeButtonColor(sender: sender)
        }
    }
    func changeButtonColor(sender:UIButton){
        for view in self.contentView.subviews{
            if let view  = view as? UIButton{
                view.setBackgroundImage(UIImage(named:"background_icon"), for: .normal)
                view.setTitleColor(customGray, for: .normal)
                
            }
        }
        sender.setBackgroundImage(UIImage(named:"selectBackground_icon"), for: .normal)
        sender.setTitleColor(.white, for: .normal)
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  PointBuyChildCollectionViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/26.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
import SnapKit
extension Dictionary where Key:ExpressibleByStringLiteral,Value:Any {
    func name(){
        
    }
}
class ProgressBar: UIView {
     var widthConstraint:Constraint?
    var overView = UIView()
    var overLabel = UILabel()
    override func draw(_ rect: CGRect) {
        super.draw(rect)
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(overView)
        self.addSubview(overLabel)
        self.setAllAttributes()
        
    }
    convenience init(allCount:Int,overCount:Int){
        self.init(frame: CGRect.zero)
        
    }
    func setAllAttributes(){
        self.backgroundColor = UIColor.hexStringToColor("ffd4dc")
        overView.snp.makeConstraints { (make) in
           make.left.top.bottom.equalToSuperview()
           make.width.equalToSuperview()
        }
        overView.backgroundColor = UIColor.hexStringToColor("ff8fa4")
        overLabel.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.height.equalToSuperview().multipliedBy(0.8)
        }
        overLabel.setFontAndTextColor(font: MiddleFont, textColor: .white)
    }
    func setOverCount(overCount:Int,allCount:Int){
        let radio = CGFloat(overCount)/CGFloat(allCount)
    
        //updateConstraints约束失败原因不不明上面测试普通的约束可以 带比例的貌似不行
//        overView.snp.updateConstraints { (make) in
//
//            make.width.equalToSuperview().offset(-100)
//
//        }
        overView.snp.remakeConstraints { (make) in
            make.left.top.bottom.equalToSuperview()
            make.width.equalToSuperview().multipliedBy(radio)
        }
        overLabel.text = "已抢\(overCount)"
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
class PointBuyChildCollectionViewCell: UICollectionViewCell {
    var goodsImageView = UIImageView()
    var goodsNameLabel = UILabel()
    var newPriceLabel = UILabel()
    var oldPriceLabel = UILabel()
    var buyButton = UIButton()
    var progressBar = ProgressBar()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.backgroundColor = .white
        self.contentView.addSubview(goodsImageView)
        self.contentView.addSubview(goodsNameLabel)
        self.contentView.addSubview(newPriceLabel)
        self.contentView.addSubview(oldPriceLabel)
        self.contentView.addSubview(buyButton)
        self.contentView.addSubview(progressBar)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFormat()
    }
    
    func setLayout(){
        goodsImageView.snp.makeConstraints { (make) in
            make.width.equalToSuperview()
            make.height.equalTo(goodsImageView.snp.width)
            make.left.top.equalToSuperview()
        }
        goodsNameLabel.snp.makeConstraints { (make) in
            make.left.equalTo(goodsImageView).offset(10)
            make.top.equalTo(goodsImageView.snp.bottom).offset(10)
            make.height.equalTo(11)
        }
        newPriceLabel.snp.makeConstraints { (make) in
            make.left.equalTo(goodsNameLabel)
            make.top.equalTo(goodsNameLabel.snp.bottom).offset(10)
        }
        oldPriceLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(newPriceLabel)
            make.left.equalTo(newPriceLabel.snp.right).offset(5)
        }
        buyButton.snp.makeConstraints { (make) in
            make.bottom.equalTo(progressBar.snp.top)
            make.right.equalToSuperview()
            make.width.equalTo(60)
            make.height.equalTo(35)
        }
        progressBar.snp.makeConstraints { (make) in
            make.height.equalTo(20)
            make.left.right.bottom.equalToSuperview()
        }

    }
    func setData(){
        self.goodsImageView.image = #imageLiteral(resourceName: "bourkestreetbakery")
        self.goodsNameLabel.text = "ML时尚鸭舌帽"
        self.newPriceLabel.text = "￥120"
        self.oldPriceLabel.text = "￥200"
        self.buyButton.setTitle("马上抢", for: .normal)
        self.progressBar.setOverCount(overCount: 100, allCount: 200)
        
        
    }
    func setFormat(){
        self.goodsNameLabel.setFontAndTextColor(font: MiddleFont, textColor: UIColor.black)
        self.newPriceLabel.setNewLabel(headerFontSize: 8, footerFontSize: 10)
        self.oldPriceLabel.setOldLabel(fontSize: 8)
        self.buyButton.setBackgroundImage(UIImage(named:"btn_sel_red_120x70"), for: .normal)
        self.buyButton.titleEdgeInsets = UIEdgeInsets(top: -5, left: 0, bottom: 0, right: 0)
        self.buyButton.titleLabel?.font = MiddleFont
        self.buyButton.titleLabel?.textColor = .white
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
<file_sep>//
//  GoodsDetailsViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/20.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
import KNSemiModalViewController
import CoreMotion
import MWPhotoBrowser

class GoodsDetailsViewControlleabr: UIViewController,UITableViewDelegate,UITableViewDataSource,SpecViewDelegate,SDCycleScrollViewDelegate,MWPhotoBrowserDelegate{
    var photosArray :[String] =  ["headerImage","1","headerImage","headerImage"]
    var photos :[MWPhoto] = []
    var thumbs :[MWPhoto] = []
    let detailCellIdentifier = "detailCell"
    let selectCellIdentifier = "selectCell"
    let bottomCellIdentifier = "bottomCell"
    var tableView = UITableView(frame: CGRect.zero, style: .grouped)
    var bannerView = SDCycleScrollView()
    var topView  = DetailsTopView()
    lazy var motionManager = CMMotionManager()
    var timeInterval :Double = 0
    var firstAngle: Double!
    var angle :Double = 0
    var index = 0
    var newBannerView:SDCycleScrollView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.navigationBar.isTranslucent = true
        self.automaticallyAdjustsScrollViewInsets = false
        self.view.backgroundColor = .white
        self.view.addSubview(tableView)
        self.view.addSubview(topView)
        topView.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.top.equalToSuperview().offset(64)
            make.height.equalTo(35)
        }
        self.addBackItem()
        self.setTableView()
        self.setBannerView()
        self.setNavigationItem()
        self.addBottomButton()
    }
    //陀螺仪旋转角度转换成图片下标
    func calculateRotationByGyro(motion:CMDeviceMotion){
        print("转动中")
        let y = motion.rotationRate.y
        let timeInterval = Date().timeIntervalSince1970
        angle += y*(timeInterval - self.timeInterval)*(180.0 / M_PI)
        if self.firstAngle == nil{
            self.firstAngle = angle
        }
        self.timeInterval = timeInterval
        var index = Int(firstAngle - angle)/3
        if index > 0 {
            index = index % 16

        }else{
            index = (index%16 + 16) % 16
        }
        if index != self.index{
            self.becomeImage(index: index)
            self.index = index
        }
        
    }
    //切换图片
    func becomeImage(index:Int){
        self.photosArray[1] = "\(index)"
        self.bannerView.localizationImageNamesGroup = self.photosArray
        for view in self.bannerView.subviews{
            if let view = view as? UICollectionView{
                //当前第几张图片
              view.reloadData()
            }
        }
        self.newBannerView.localizationImageNamesGroup = self.photosArray
        
        for view in self.newBannerView.subviews{
            if let view = view as? UICollectionView{
                //当前第几张图片
                view.reloadData()
            }
        }

        
    }
    /// 添加底部button
    func  addBottomButton(){
        let addCartButton = UIButton()
        addCartButton.backgroundColor = customGray
        addCartButton.setTitle("加入购物车", for: .normal)
        addCartButton.titleLabel?.font = BigFont
        self.view.addSubview(addCartButton)
        addCartButton.snp.makeConstraints { (make) in
            make.width.equalToSuperview().multipliedBy(0.5)
            make.height.equalTo(40)
            make.left.bottom.equalToSuperview()
        }
        addCartButton.addTarget(self, action: #selector(GoodsDetailsViewControlleabr.addCartAction(_:)), for: .touchUpInside)
        let sureBuyButton = UIButton()
        sureBuyButton.backgroundColor = customRed
        sureBuyButton.setTitle("立即购买", for: .normal)
        sureBuyButton.titleLabel?.font = BigFont
        self.view.addSubview(sureBuyButton)
        sureBuyButton.snp.makeConstraints { (make) in
            make.width.equalToSuperview().multipliedBy(0.5)
            make.height.equalTo(40)
            make.right.bottom.equalToSuperview()
        }
        sureBuyButton.addTarget(self, action: #selector(GoodsDetailsViewControlleabr.sureBuyAction(_:)), for: .touchUpInside)


    }
    
    func addCartAction(_ sender:UIButton){
        print("添加成功")
    }
    //确认购买
    func sureBuyAction(_ sender:UIButton){
        let confirmOrderViewController = DetailsStoryboardHelper.instantiateViewController(identifier: DetailsStoryboardHelper.confirmOrderViewController)
        self.navigationController?.pushViewController(confirmOrderViewController, animated: true)
    }

    //设置导航栏
    private func setNavigationItem(){
        let rightButtonItem = UIBarButtonItem(image: UIImage(named:"messageItem"),style: .plain, target: self,  action: nil)
        self.navigationItem.rightBarButtonItem = rightButtonItem
    }
    //设置tableView
    private func setTableView(){
        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.backgroundColor = HiTaoBackgroundColor
        tableView.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-40)
            make.top.equalToSuperview().offset(64+35)
        }
        self.tableView.separatorStyle = .none
        self.tableView.register(GoodsTableViewCell.self, forCellReuseIdentifier: detailCellIdentifier)
        self.tableView.register(GoodsSelectTableViewCell.self, forCellReuseIdentifier: selectCellIdentifier)
        self.tableView.register(GoodsBottomTableViewCell.self, forCellReuseIdentifier: bottomCellIdentifier)
        
    }
    //设置轮播图
    private func setBannerView(){
        self.bannerView.frame = CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 300)
        self.bannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight
        self.bannerView.currentPageDotImage = UIImage(named:"ellipse_red")
        self.bannerView.pageDotImage = UIImage(named: "ellipse_gray")
        self.bannerView.autoScroll = false
        self.bannerView.infiniteLoop = false
        self.bannerView.delegate = self
        self.bannerView.localizationImageNamesGroup = ["headerImage","1","headerImage","headerImage"]

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    //MARK: SDCycleScrollViewDelegate
    func cycleScrollView(_ cycleScrollView: SDCycleScrollView!, didScrollTo index: Int){
        if index == 1{
            self.motionManager.startDeviceMotionUpdates(to: OperationQueue.main, withHandler:
                {motion,error in
                    self.calculateRotationByGyro(motion: motion!)
            })
        }else{
            motionManager.stopDeviceMotionUpdates()
        }
       
    }
    func cycleScrollView(_ cycleScrollView: SDCycleScrollView!, didSelectItemAt index: Int) {

        let browser = MWPhotoBrowser(delegate: self)
        //分享按钮,默认是
        browser?.displayActionButton = false
        //左右分页切换,默认否
        browser?.displayNavArrows = false
        //是否显示选择按钮在图片上,默认否
        browser?.displaySelectionButtons = false
        //控制条件控件 是否显示,默认否
        browser?.alwaysShowControls = false
        //是否全屏,默认是
        browser?.zoomPhotosToFill = true
        //是否允许用网格查看所有图片,默认是
        browser?.enableGrid = true
        //是否第一张,默认是
        browser?.startOnGrid = true
        //扫图消失
        browser?.enableSwipeToDismiss = true
        //设置显示第几张
        browser?.setCurrentPhotoIndex(UInt(index))
        
        photos = [MWPhoto(image: UIImage(named: photosArray[0])),MWPhoto(image: UIImage(named: photosArray[1])),MWPhoto(image: UIImage(named: photosArray[2])),MWPhoto(image: UIImage(named: photosArray[3]))]
        thumbs = [MWPhoto(image: UIImage(named: photosArray[0])),MWPhoto(image: UIImage(named: photosArray[1])),MWPhoto(image: UIImage(named: photosArray[2])),MWPhoto(image: UIImage(named: photosArray[3]))]
       let nc = UINavigationController(rootViewController: browser!)
       nc.modalTransitionStyle = .crossDissolve
       self.present(nc, animated: true, completion:nil)
       //自定义添加点击消失和导航栏消失
       browser?.addTouchTap()

    }
    //MARK:- MWPhotoBrowserDelegate
    func numberOfPhotos(in photoBrowser: MWPhotoBrowser!) -> UInt{
        return 4
    }
    func photoBrowser(_ photoBrowser: MWPhotoBrowser!, photoAt index: UInt) -> MWPhotoProtocol! {
        return photos[Int(index)]
    }

    //MARK:- UITableViewDataSource
    func numberOfSections(in tableView: UITableView) -> Int {
        return 3
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
        return 1
    }
    
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
        switch indexPath.section {
        case 0:
            let cell = tableView.dequeueReusableCell(withIdentifier: detailCellIdentifier, for: indexPath)
            return cell
        case 1:
            let cell = tableView.dequeueReusableCell(withIdentifier: selectCellIdentifier, for: indexPath)
            return cell
        default :
            let cell = tableView.dequeueReusableCell(withIdentifier: bottomCellIdentifier, for: indexPath)
            cell.selectionStyle = .none
            return cell
        }
       
        
    
    }
    
    //MARK: - UITableViewDelegate
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        switch indexPath.section {
        case 0:
            return  110
        case 1:
            return 30
        default :
            return 265
        }
    }
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        switch section {
        case 0:
            return  300
        default:
            return 0.0001
        }
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        if section == 0{
            return bannerView
        }else{
            return nil
        }
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 10
    }

    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let view = SpecView(frame: CGRect(x: 0, y: 0, width: 0, height: 300))
        view.delegate = self
        if indexPath.section == 1{
            let dict :NSDictionary  = [KNSemiModalOptionKeys.pushParentBack : true,
                                       KNSemiModalOptionKeys.animationDuration  : 2,
                                       KNSemiModalOptionKeys.shadowOpacity   : 0.3,]
            self.presentSemiView(view, withOptions: dict as! [AnyHashable:Any] )
        }
        tableView.deselectRow(at: indexPath, animated: true)
        
    }
    //MARK:- SpecViewDelegate
    func disMissModleView() {
        self.dismissSemiModalView()
    }
    
}

<file_sep>//
//  ProgressCircleView.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/22.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class ProgressCircleView: UIView {
   var bgView = UIImageView()
   var topLabel = UILabel()
   var bottomLabel = UILabel()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(bgView)
        self.addSubview(topLabel)
        self.addSubview(bottomLabel)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setFrame()
    }
    
    func setLayout(){
        bgView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        topLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.bottom.equalTo(self.bgView.snp.centerY).offset(-3.5-3)
        }
        bottomLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(self.bgView.snp.centerY).offset(-3.5+3)
        }
    
        
    }
    func setData(visualCount:Int,allCount:Int){
        self.topLabel.text = String(visualCount)
        self.bottomLabel.text = String(allCount)
    }
    func setFrame(){
        self.bgView.image = #imageLiteral(resourceName: "icon_progress")
        self.topLabel.font = SmallFont
        self.bottomLabel.font = SmallFont
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
<file_sep>//  TableChildExampleViewController.swift
//  XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip )
//
//  Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import Foundation
import XLPagerTabStrip

class TableChildExampleViewController: UIViewController, IndicatorInfoProvider ,UITableViewDataSource,UITableViewDelegate{
    var index:Int!
    let cheapCellIdentifier = "cheapCell"
    let hotCellIdentifier = "hotCell"
    let newCellIdentifier = "newCell"

    var blackTheme = false
    var itemInfo : IndicatorInfo!
    var tableView = UITableView()

    init(itemInfo: IndicatorInfo,index:Int) {
        self.itemInfo = itemInfo
        self.index = index
        super.init(nibName: nil, bundle: nil)
      
    }

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //最后一个需要背景色
        if index == 2{
            self.view.backgroundColor = HiTaoBackgroundColor
        }
        self.view.addSubview(tableView)
        self.tableView.separatorStyle = .none
        self.tableView.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            if index == 2{
                make.top.equalToSuperview().offset(2)
            }else{
                 make.top.equalToSuperview()
            }
            make.bottom.equalToSuperview()
        }
        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.register(NewCheapTableViewCell.self, forCellReuseIdentifier: cheapCellIdentifier)
        self.tableView.register(NewHotTableViewCell.self, forCellReuseIdentifier: hotCellIdentifier)
        self.tableView.register(NewTableViewCell.self, forCellReuseIdentifier: newCellIdentifier)

        self.tableView.estimatedRowHeight = 60.0;
        self.tableView.rowHeight = UITableViewAutomaticDimension
        self.tableView.allowsSelection = false
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.tableView.reloadData()
        self.tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: true)
    }
    override func viewWillDisappear(_ animated: Bool) {
    }
    
    // MARK: - UITableViewDataSource

    
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return   5
    }

     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        var cell = UITableViewCell()
        switch index {
        case 0:
            cell = tableView.dequeueReusableCell(withIdentifier: cheapCellIdentifier, for: indexPath) as! NewCheapTableViewCell
        case 1:
            cell = tableView.dequeueReusableCell(withIdentifier: hotCellIdentifier, for: indexPath) as! NewHotTableViewCell
        case 2:
            cell = tableView.dequeueReusableCell(withIdentifier: newCellIdentifier, for: indexPath) as! NewTableViewCell
        default:
            break
        }
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return index == 2 ?  110 + ITEM_WIDTH*(80/93)*2 : 240
    }
    
    // MARK: - IndicatorInfoProvider

    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return itemInfo
    }
   
    
}
<file_sep>//
//  BrandViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/22.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class BrandViewController: UIViewController ,UICollectionViewDataSource,UICollectionViewDelegate{
    let brandColCellIdentifier = "brandColCell"
    var collectionView :UICollectionView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        self.navigationItem.title = "品牌"
        self.setCollectionView()
        self.setNavigationItem()

    }
    private func setNavigationItem(){
        let rightItem = UIBarButtonItem(image: UIImage(named:navIconMessage), style: .plain, target: self, action: nil)
        self.navigationItem.rightBarButtonItem = rightItem
    }
    private func setCollectionView(){
        let layout = PublicCollectionViewLayout(sectionInset: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10), minimumLineSpacing: 10, minimumInteritemSpacing: 10, itemSize:CGSize(width: (SCREEN_WIDTH-41)/3, height:(SCREEN_WIDTH-41)/3 + 30))
        self.collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout:layout)
        self.collectionView.delegate = self
        self.collectionView.dataSource = self
        self.view.addSubview(collectionView)
        self.collectionView.backgroundColor = HiTaoBackgroundColor
        collectionView.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.top.equalToSuperview()
        }
        self.collectionView.register(BrandCollectionViewCell.self, forCellWithReuseIdentifier: brandColCellIdentifier)

    }
    
//MARK:- UICollectionDataSource
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 30
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: brandColCellIdentifier, for: indexPath) as! BrandCollectionViewCell
        return cell
    }
//MARK:- UICollectionDelegate



}
<file_sep>//
//  WaterFlowViewLayout.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/10.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class WaterFlowViewLayout: UICollectionViewLayout {
    
    ///所有cell的布局属性
    var layoutAttributes = [UICollectionViewLayoutAttributes]()
    
    ///使用一个字典记录每列的最大Y值
    var maxYDict = [Int:CGFloat]()
    ///瀑布流四周的间距
    var sectionInsert :UIEdgeInsets!
    //列间距
    var columnMargin:CGFloat!
    
    //行间距
    var rowMargin:CGFloat!
    
    ///瀑布流列数
    var columnCount : Int!

    //高度计算回调方法
    var itemHeightBlock : ((CGFloat, IndexPath) -> CGFloat)!
    
    
    override func prepare() {
        for i in 0 ..< self.columnCount {
            self.maxYDict[i] = self.sectionInsert.top
        }
        let itemCount  = self.collectionView?.numberOfItems(inSection: 0)
        for i in 0 ..< itemCount!{
           let attributes = self.layoutAttributesForItem(at: IndexPath(item: i, section: 0))
           self.layoutAttributes.append(attributes!)
        }
    }
    
    
    override var collectionViewContentSize: CGSize{
        get{
            var maxIndex:Int = 0
            for(key,value) in maxYDict{
                if maxYDict[maxIndex]! < value{
                    maxIndex = key
                }
            }
            return CGSize(width:0.0,height:self.maxYDict[maxIndex]! + self.sectionInsert.bottom)
        }
    }
    
    override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
        let  collectionViewWidth =  self.collectionView?.frame.width
        let itemWidth :CGFloat = (collectionViewWidth! - self.sectionInsert.left - self.sectionInsert.right - CGFloat((self.columnCount - 1)) * self.columnMargin) / CGFloat(columnCount)
        var minIndex = 0
        for(key,value) in maxYDict{
            if maxYDict[minIndex]! > value{
                minIndex = key
            }
        }
        let itemX = self.sectionInsert.left + (self.columnMargin + itemWidth) * CGFloat(minIndex)
        let itemY = self.maxYDict[minIndex]! + self.rowMargin
        let itemHeight = self.itemHeightBlock(itemWidth,indexPath)
        //设置cell的frame
        let frame = CGRect(x: itemX, y: itemY, width: itemWidth, height: itemHeight)
        //更新最短这列的最大Y值
        maxYDict[minIndex] = frame.maxY
        let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath)
        attributes.frame = frame
        return attributes
    }
    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        return self.layoutAttributes
    }
    
}
<file_sep>//
//  SpecSizeModel.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/24.
//  Copyright © 2016年 周. All rights reserved.
//

import Foundation


struct SpecSizeModel {
    var sizeName:String
    var isSelect:Bool
}
<file_sep>//
//  PointBuyChildViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/26.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
import XLPagerTabStrip

class PointBuyChildViewController: UIViewController,IndicatorInfoProvider,UICollectionViewDelegate,UICollectionViewDataSource {
    //整点秒杀单元的Identifier
    let pointBuyChildCellIdentifier = "pointBuyChildCell"
    //collectionHeader的Identifier
    let collectionHeaderIdentifier =  "collectionHeader"
    var index:Int!
    var itemInfo : IndicatorInfo!
    var collectionView:UICollectionView!
    init(itemInfo: IndicatorInfo,index:Int) {
        self.itemInfo = itemInfo
        self.index = index
        super.init(nibName: nil, bundle: nil)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = HiTaoBackgroundColor
        self.setCollectionView()

    }
    

    
   //设置collectionView
    private func setCollectionView(){
        //初始化layout
        let layout = PublicCollectionViewLayout(sectionInset: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10), minimumLineSpacing: 10, minimumInteritemSpacing: 10, itemSize:CGSize(width: (SCREEN_WIDTH-30)/2, height: (SCREEN_WIDTH-30)/2 + 80))
        //头部尺寸
        layout.headerReferenceSize = CGSize(width: SCREEN_WIDTH , height: 40)
        //设置内部layout
        self.collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout:layout)
        //指定代理
        self.collectionView.delegate = self
        self.collectionView.dataSource = self
        self.view.addSubview(collectionView)
        //设置背景颜色
        self.collectionView.backgroundColor = HiTaoBackgroundColor
        //添加约束
        collectionView.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.top.equalToSuperview()
            
        }
        //注册单元
        self.collectionView.register(PointBuyChildCollectionViewCell.self, forCellWithReuseIdentifier: pointBuyChildCellIdentifier)
        self.collectionView.register(CountDownCollectionHeaderView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier:collectionHeaderIdentifier )
      
    }


    //MARK: - UICollectionViewDataSource
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 30
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: pointBuyChildCellIdentifier, for: indexPath)
        return cell
    }
    //MARK: - UICollectionViewDelegate
    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
        let cell =  collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: collectionHeaderIdentifier, for: indexPath) as! CountDownCollectionHeaderView
        return cell
        
        
    }
    // MARK: - IndicatorInfoProvider
    
    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        return itemInfo
    }


}
<file_sep>//
//  GoodsSelectTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/24.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class GoodsSelectTableViewCell: UITableViewCell {
   var selectLabel = UILabel()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(selectLabel)
        selectLabel.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(20)
            make.width.equalTo(150)
            make.height.equalToSuperview()
        }
        selectLabel.font = MiddleFont
        selectLabel.text = "请选择"
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  WeChatSearchController.swift
//  SuperWeChat
//
//  Created by 周鹏杰 on 16/9/19.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit



class WeChatSearchViewController: UISearchController{

    
    
    override init(searchResultsController: UIViewController!) {
        super.init(searchResultsController: searchResultsController)
        self.setSearchBar()
    }
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置textField
    func setSearchBar(){
        if let index = indexOfSearchFieldInSubviews() {
            // 获取搜索输入框
            let searchField: UITextField = (searchBar.subviews[0]).subviews[index] as! UITextField
            searchField.placeholder = "请输入搜索内容"
        }
        //设置bookMarkButton图标
        self.searchBar.showsBookmarkButton = true
        self.searchBar.setImage(UIImage(named:"scanning_icon"), for: .bookmark, state: .normal)
        self.searchBar.barTintColor = RGB(r: 201, g: 201, b: 206)
        self.searchBar.searchBarStyle = .default
        self.searchBar.tintColor = RGB(r: 38, g: 202, b: 114)

    }
    //获取textField索引
    func indexOfSearchFieldInSubviews() -> Int! {
        var index: Int!
        let searchBarView = searchBar.subviews[0]
        for i in 0 ..< searchBarView.subviews.count {
            if searchBarView.subviews[i] is UITextField {
                index = i
                break
            }
        }
        return index
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        //设置控制器
        self.setSearchController()
        //设置Bar视图的颜色
        self.setSearchBar()
        //搜索结果更新者为当前控制器
        self.setDelegate()
    }
    func setSearchController(){
        //搜索时，背景变暗色
        self.dimsBackgroundDuringPresentation = false
        //搜索是背景变模糊
        if #available(iOS 9.1, *) {
            self.obscuresBackgroundDuringPresentation = false
        } else {
            // Fallback on earlier versions
        }
        //设置背景色
        self.view.backgroundColor = UIColor.clear
    }

    func setDelegate(){
//        self.searchResultsUpdater = VM
//        self.delegate = VM
//        self.searchBar.delegate = VM
//        self.customSearchBar.delegate = VM
//        VM.viewDelegate = self
//        VM.customDelegate = self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    
    

    
    func becomeActive(){
        self.isActive = true
    }
    
    //MARK: -- CustomSearchControllerDelegate
    func didStartSearching(){
        print("开始")
    }
    
    func didTapOnSearchButton(){
        print("搜索")
    }
    
    func didTapOnCancelButton(){
        print("取消")
    }

    
    func didChangeSearchText(searchText: String){
        print("正在输入\(searchText)")
    }


}
<file_sep>//
//  BrandCollectionViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/22.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class BrandCollectionViewCell: UICollectionViewCell {
    var brandImageView = UIImageView()
    var brandLabel = UILabel()
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(brandImageView)
        self.contentView.addSubview(brandLabel)
        self.setAllAttributes()
    }
    func setAllAttributes(){
        self.setLayout()
        self.setData()
        self.setFrame()
    }
    
    func setLayout(){
        brandImageView.snp.makeConstraints { (make) in
            make.width.equalToSuperview()
            make.height.equalTo(brandImageView.snp.width)
            make.left.top.equalToSuperview()
        }
        brandLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.equalTo(brandImageView.snp.bottom).offset(5)
        }
    }
    func setData(){
        brandImageView.image = UIImage(named:imageDefaultName)
        self.brandLabel.text = "阿迪王"
    }
    func setFrame(){
        self.brandLabel.font = BigFont
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
}
<file_sep>//
//  MineHeaderView.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/19.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
protocol MineHeaderViewDelegate :NSObjectProtocol{
    func pushToMineOrderViewController()
}
class MineHeaderView: UITableViewHeaderFooterView {

   var headerTitleLabel = UILabel()
   var moreButton = UIButton()
    
    var delegate : MineHeaderViewDelegate!
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        self.contentView.backgroundColor =  HiTaoBackgroundColor
        self.contentView.addSubview(headerTitleLabel)
        self.contentView.addSubview(moreButton)
        self.setAllAttributes()
    }
    
    
    func setAllAttributes(){
        self.setLayout()
        self.setFormat()
    }
    
    
    func setLayout(){
        headerTitleLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(10)
            make.centerY.equalToSuperview()
        }
        moreButton.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview()
        }
    }
    func setData(title:String){
        self.headerTitleLabel.text = title
        self.moreButton.setImage(UIImage(named:"icon_arrow_right_more"), for: .normal)
        self.moreButton.addTarget(self, action: #selector(MineHeaderView.moreAction(_:)), for: .touchUpInside)
        
    }
    
    func moreAction(_ sender:UIButton){
        self.delegate.pushToMineOrderViewController()
    }
    func setFormat(){
        self.headerTitleLabel.font = BigFont
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
<file_sep>//
//  InfoHeaderTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/30.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class InfoHeaderTableViewCell: UITableViewCell {

    @IBOutlet weak var headerImageView: UIImageView!
    override func awakeFromNib() {
        super.awakeFromNib()
        self.headerImageView.ViewToRoundView()
      
        
    }
  
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  ClassCollectionViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/12.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class ClassCollectionViewCell: UICollectionViewCell {
    
    
    @IBOutlet weak var imageView: UIImageView!
    
    @IBOutlet weak var titleLabel: UILabel!
    
    override func awakeFromNib() {
        
    }
}
<file_sep>//
//  NewTableViewCell.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/14.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class NewTableViewCell: UITableViewCell,UICollectionViewDataSource {
    let productCellIdentifier = "productCell"
    var businessHeadImageView = UIImageView()
    var businessNameLabel = UILabel()
    var beforeTimeLabel = UILabel()
    var followButton = UIButton()
    var collectionView : UICollectionView!
    var bottomColorView = UIView()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        let layout  = PublicCollectionViewLayout(sectionInset: UIEdgeInsets(top: 20, left: 10, bottom: 20, right: 10), minimumLineSpacing: 10, minimumInteritemSpacing: 10.5, itemSize: CGSize(width: ITEM_WIDTH, height: ITEM_WIDTH*(80/93)))
        collectionView = UICollectionView(frame:CGRect.zero, collectionViewLayout: layout)
        collectionView.collectionViewLayout = layout
        self.contentView.addSubview(businessHeadImageView)
        self.contentView.addSubview(businessNameLabel)
        self.contentView.addSubview(beforeTimeLabel)
        self.contentView.addSubview(collectionView)
        self.contentView.addSubview(followButton)
        self.contentView.addSubview(bottomColorView)
        self.setContentInCell()
    }
    
    func setContentInCell(){
        self.setLayout()
        self.setData()
        self.setFormat()
    }
    func setLayout(){
        self.businessHeadImageView.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.top.equalToSuperview().offset(20)
            make.width.height.equalTo(30)
        }
        self.businessNameLabel.snp.makeConstraints { (make) in
            make.left.equalTo(businessHeadImageView.snp.right).offset(5)
            make.top.equalToSuperview().offset(20)
        }
        self.beforeTimeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(businessNameLabel)
            make.top.equalTo(businessNameLabel.snp.bottom).offset(5)
        }
        self.collectionView.snp.makeConstraints { (make) in
            make.top.equalTo(businessHeadImageView.snp.bottom)
            make.left.right.equalToSuperview()
            make.bottom.equalTo(bottomColorView.snp.top)
        }
        self.followButton.snp.makeConstraints { (make) in
            make.centerY.equalTo(businessHeadImageView).offset(4)
            make.right.equalToSuperview().offset(-10)
            make.width.equalTo(60)
            make.height.equalTo(35)
        }
        self.bottomColorView.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(10)
        }
    }
    func setData(){
        self.businessHeadImageView.image = UIImage(named:"bourkestreetbakery")
        self.businessNameLabel.text = "他叫向日葵"
        self.beforeTimeLabel.text = "3分钟前"
        self.collectionView.dataSource = self
        self.collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: productCellIdentifier)
        self.followButton.setTitle("+关注", for: .normal)
    }
    func setFormat(){
        self.businessNameLabel.font = MiddleFont
        self.beforeTimeLabel.font = SmallFont
        self.beforeTimeLabel.textColor = UIColor.hexStringToColor("94a3b5")
        self.collectionView.isScrollEnabled = false
        self.collectionView.backgroundColor = .white
        self.bottomColorView.backgroundColor = HiTaoBackgroundColor
        self.followButton.setBackgroundImage(UIImage(named:"btn_sel_red_120x70"), for: .normal)
        self.followButton.titleLabel?.font = MiddleFont
        self.followButton.setTitleColor(.white, for: .normal)
        self.followButton.titleEdgeInsets.top = -5
    }
    
  //layoutIfNeeded：告知页面布局立刻更新。所以一般都会和setNeedsLayout一起使用。如果希望立刻生成新的frame需要调用此方法，利用这点一般布局动画可以在更新布局后直接使用这个方法让动画生效。
    override func layoutIfNeeded() {
        super.layoutIfNeeded()
        self.businessHeadImageView.ViewToRoundViewBycornerRadius(cornerRadius: 15)
    }
    
    
    public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{
        return 6
    }
    

    public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
        let cell  = collectionView.dequeueReusableCell(withReuseIdentifier: productCellIdentifier, for: indexPath)
        cell.backgroundColor = UIColor.randomColor()
        return cell
        
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
<file_sep>//
//  Range+Extension.swift
//  SuperWeChat
//
//  Created by 周鹏杰 on 16/9/20.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit


extension NSRange{
    
    /// NSRange转换成Range<String.Index>
    ///
    /// - Parameter content: 内容字符串
    /// - Returns: 返回Range<String.Index>
    func toRangeByString(content:String) -> Range<String.Index> {
        let startIndex =  content.characters.index(content.startIndex, offsetBy: self.location)
        let endIndex = content.characters.index(content.startIndex, offsetBy: self.location + self.length)
        let newRange :Range<String.Index> = Range(uncheckedBounds: (startIndex,endIndex))
        return newRange
    }
   
}






<file_sep>//
//  SearchTopView.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/25.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class SearchTopView: UIView {

    
    

}
<file_sep>//
//  PointBuyViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/26.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit
import Popover
import XLPagerTabStrip
class PointBuyViewController: ButtonBarPagerTabStripViewController {
    //第一次加载
    var isFirst = true
    override func viewDidLoad(){
        self.view.backgroundColor = .white
        settings.style.buttonBarHeight = 50
        settings.style.buttonBarBackgroundColor = .white
        settings.style.buttonBarItemBackgroundColor = .white
        settings.style.selectedBarBackgroundColor =  .black
        settings.style.buttonBarItemFont = .systemFont(ofSize: 11)
        settings.style.selectedBarHeight = 0
        settings.style.buttonBarMinimumLineSpacing = 0
        settings.style.buttonBarItemTitleColor = customGray
        settings.style.buttonBarItemsShouldFillAvailiableWidth = true
        settings.style.buttonBarLeftContentInset = 0
        settings.style.buttonBarRightContentInset = 0
        changeCurrentIndexProgressive = {  (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
            guard changeCurrentIndex == true else { return }
            //保证把所有颜色先变成未选中状态
            if !self.isFirst{
                for subview in self.buttonBarView.subviews{
                    if let cell = subview as? ButtonBarViewCell{
                        cell.label.textColor = .black
                    }
                }
            }
            oldCell?.label.textColor = customGray
            newCell?.label.textColor = .black
        }
        super.viewDidLoad()
     
   
    }
    override func viewWillDisappear(_ animated: Bool) {
        self.isFirst = false

    }
    override func viewWillAppear(_ animated: Bool) {
    }
  
    @IBAction func showMenu(_ sender: UIBarButtonItem) {
        self.setRightPopoverView()

    }

   
    /// 设置右侧弹出框
    private func setRightPopoverView(){
        let startPoint = CGPoint(x: SCREEN_WIDTH - 80, y: 64)
        let options = [
            .type(.down),
            .cornerRadius(10),
            .animationIn(0.3),
            .blackOverlayColor(RGBAndAlpha(r: 222, g: 222, b: 222, a: 0.8)),
            .arrowSize(CGSize.zero)
            ] as [PopoverOption]
        let popover = Popover(options: options, showHandler: nil, dismissHandler: nil)
        let view = MenuContentView(frame:CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 0))
        //设置闭包可以回传选择值 暂时只做了页面消失
        view.completion = {
            popover.dismiss()
        }
        popover.show(view, point: startPoint)
  
    }
//    //设置导航栏
//    private func setNavigationItem(){
//        self.navigationController?.navigationBar.isTranslucent = false
//    }
    //头部移动
    private  func moveToIndex(index:Int){
        if self.canMoveTo(index: index){
            self.moveToViewController(at: index, animated: true)
         }
    }
    

    //设置子viewController
    override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
        let child_1 = PointBuyChildViewController( itemInfo: IndicatorInfo(title: "10:00\n已经秒杀"),index:0)
        let child_2 = PointBuyChildViewController( itemInfo: IndicatorInfo(title: "11:00\n已经秒杀"),index:1)
        let child_3 = PointBuyChildViewController( itemInfo: IndicatorInfo(title: "13:00\n正在秒杀"),index:2)
        let child_4 = PointBuyChildViewController( itemInfo: IndicatorInfo(title: "15:00\n将要秒杀"),index:2)
        let child_5 = PointBuyChildViewController( itemInfo: IndicatorInfo(title: "17:00\n将要秒杀"),index:2)
    
        return [child_1, child_2,child_3,child_4,child_5]
    }

   
}
<file_sep>//
//  MineViewController.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/10/18.
//  Copyright © 2016年 周. All rights reserved.
//

import UIKit

class MineViewController: UIViewController,UITableViewDelegate,UITableViewDataSource ,MineHeaderViewDelegate{
    let mineHeaderCellIdentifier = "mineHeaderCell"
    let mineSecondeCellIdentifier = "mineSecondCell"
    let mineThirdeCellIdentifier = "mineThirdCell"
    let mineHeaderViewIdenetifier = "mineHeaderView"
    let sectionTitleArray = ["我的订单","必备工具","生活·健康"]
    
    
    @IBOutlet weak var tableView: UITableView!
    
    @IBAction func showMineCoupon(_ sender: UIButton) {
        let vc = CouponViewController()
        vc.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
    @IBAction func showMineCollection(_ sender: UIButton) {
        let vc = MineCollectionViewController()
        vc.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(vc, animated: true)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addBackItem()
        //注册头部单元
        self.tableView.register(MineHeaderView.self, forHeaderFooterViewReuseIdentifier: mineHeaderViewIdenetifier)
        // 设置tableview分割线样式
        self.tableView.separatorStyle = .none
    }
    override func viewWillAppear(_ animated: Bool) {
        //设置导航栏背景图片
        self.navigationController?.navigationBar.setBackgroundImage(HiTaoBackgroundColor.imageFromColor().reSizeImage(reSize: CGSize(width: SCREEN_WIDTH, height: 64)), for: .default)
    }
    override func viewWillDisappear(_ animated: Bool) {
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //MARK: --UITableViewDataSource

    func numberOfSections(in tableView: UITableView) -> Int {
        return 4
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = UITableViewCell()
        switch indexPath.section {
        case 0:
            let cell = tableView.dequeueReusableCell(withIdentifier: mineHeaderCellIdentifier, for: indexPath) as! MineHeaderTableViewCell
            return cell
        case 1:
            let cell = tableView.dequeueReusableCell(withIdentifier: mineSecondeCellIdentifier, for: indexPath) as! MineSecondTableViewCell
            return cell
        case 2:
            let cell = tableView.dequeueReusableCell(withIdentifier: mineThirdeCellIdentifier, for: indexPath) as! MineThirdTableViewCell
            cell.itemsCount = 8
            return cell
        case 3:
            let cell = tableView.dequeueReusableCell(withIdentifier: mineThirdeCellIdentifier, for: indexPath) as! MineThirdTableViewCell
            cell.itemsCount = 4
            return cell
        default:
            return cell
        }
        
    }
    

    //MARK:- UITableViewDelegate
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        guard section != 0 else {
            return nil
        }
        let view  = tableView.dequeueReusableHeaderFooterView(withIdentifier: mineHeaderViewIdenetifier) as! MineHeaderView
        
        if [2,3].contains(section)  {
            view.moreButton.isHidden = true
        }
        view.delegate = self
        view.setData(title:sectionTitleArray[section - 1])
        let tap = UITapGestureRecognizer(target: self, action: #selector(MineViewController.pushToMineOrderViewController))
        view.addGestureRecognizer(tap)
        return view
    }
    func  tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        switch indexPath.section {
        case 0:
            return 157
        case 1:
            return  80
        case 2:
            return  80 * 2 + 1
        case 3:
            return  80
        default:
            return 100
        }
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        
        switch section {
        case 0:
             return 0.0000000001
        default:
            return 25
        }
       
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        switch section {
        case 0:
            return 0.0000000001
        default:
            return 0.0000000001
        }
    }
    
    //MARK: -- MineHeaderViewDelegate
    func pushToMineOrderViewController() {
        let vc = MineOrderViewController()
        vc.hidesBottomBarWhenPushed = true
          self.navigationController?.pushViewController(vc, animated: true)
    }
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        segue.destination.hidesBottomBarWhenPushed = true
    }

}
<file_sep>//
//  MWPhotoBrowser+Extension.swift
//  HiShopping
//
//  Created by 周鹏杰 on 2016/11/10.
//  Copyright © 2016年 周. All rights reserved.
//

import Foundation

import MWPhotoBrowser
extension MWPhotoBrowser{
    //添加清除消失和隐藏导航栏
    func addTouchTap(){
        self.navigationController?.navigationBar.isHidden = true
        let tap =  UITapGestureRecognizer(target: self, action: #selector(MWPhotoBrowser.disMissViewController(_:)))
        self.view.addGestureRecognizer(tap)
    }
    
    /// 消失方法
    ///
    /// - Parameter sender: 手势
    func disMissViewController(_ sender:UITapGestureRecognizer){
        if self.enableGrid{
            if self.startOnGrid {
                self.showGrid(true)
                return
            }else if !self.startOnGrid{
                self.hideGrid()
                return
            }
        }
        if self.delegate.responds(to: #selector(MWPhotoBrowserDelegate.photoBrowserDidFinishModalPresentation(_:))){
           self.delegate.photoBrowserDidFinishModalPresentation!(self)
        }else{
            self.dismiss(animated: true, completion: nil)
        }
    }
    
}
