We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这里是全部代码 // HomeViewCtrl.swift // VKIntlProperty // // Created by fox on 2021/2/3. // Copyright © 2019 com.vk.TestP. All rights reserved. //
import UIKit
class VKHomeViewCtrl: VKBaseViewCtrl {
var collectionView:UICollectionView! var dataArr:Array<String>! override func viewDidLoad() { super.viewDidLoad() dataArr = ["会所预定","物业公告","我的订单","工单报事","分类标题","分类标题"] setupUI() } func setupUI() { /// 左地址选择 let leftView = UIView.init() let btn = UIButton.init(type: .custom) btn.titleOfNormal = "金色家园1栋" btn.imageOfNormal = UIImage.init(named: "nav_icon_ place") btn.titleColorOfNormal = UIColorFromHex(hexValue: Color_CommNavTitleBlack) btn.frame = CGRect.init(x: 0, y: 0, width: 140, height: 40) btn.layoutButton(with: .left, imageTitleSpace: 8) leftView.addSubview(btn) leftView.frame = CGRect.init(x: 0, y: 0, width: 140, height: 40) navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: leftView) let rightBtn = UIButton() rightBtn.layoutButton(with: .right, imageTitleSpace: 10) rightBtn.imageOfNormal = UIImage.init(named: "nav_btn_news_default") rightBtn.frame = CGRect.init(x: 0, y: 0, width: 40, height: 40) rightBtn.addTarget(self, action: #selector(pushMessageListCtr), for: .touchUpInside) navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: rightBtn) let layout = UICollectionViewFlowLayout.init() layout.scrollDirection = .vertical layout.minimumLineSpacing = 0 layout.minimumInteritemSpacing = 0 /// 如果设置家最小间距 直接给宽度会问题 layout.itemSize = CGSize.init(width:(ScreenWidth - 0 )/3, height: (ScreenWidth-0)/3) collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: layout) collectionView.dataSource = self collectionView.delegate = self collectionView.backgroundColor = UIColor.white collectionView.register(VKHomeCollectionCell.classForCoder(), forCellWithReuseIdentifier: "cellID") collectionView.register(UICollectionReusableView.classForCoder(), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "headerView") view.addSubview(collectionView) } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() collectionView.frame = view.bounds } @objc func pushMessageListCtr() { let vc = VKMessageListCtrl.init() navigationController?.pushViewController(vc, animated: true) }
}
//MARK: - UICollectionViewDataSource,UICollectionViewDelegate extension VKHomeViewCtrl: UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{ func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return dataArr.count }
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellID", for: indexPath)as! VKHomeCollectionCell cell.titleLabel.text = dataArr[indexPath.row] return cell } func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerView", for: indexPath) let pageView = TYCyclePagerView() pageView.isInfiniteLoop = true pageView.dataSource = self pageView.delegate = self pageView.register(VKHomeCarouselCell.classForCoder(), forCellWithReuseIdentifier: "VKHomeCarouselCell") pageView.frame = CGRect.init(x: 16, y: 0, width: ScreenWidth - 32, height: 172) view.addSubview(pageView) //这里放轮播图 return view } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { return CGSize(width: collectionView.bounds.width, height: 171 ) } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { var vc:UIViewController! switch indexPath.row { case 0: vc = VKClubListCtrl.init() break case 1: vc = VKNotificationListCtrl.init() break case 2: vc = VKOrderListCtrl.init() break case 3: // http://sqyypttest.vankeservice.com:9000/p/web/serviceRequest vc = VKRepairOrderCtrl.init(weburl: "http://sqyypttest.vankeservice.com:9000/p/web/serviceRequest") break default: vc = nil break } if ((vc) != nil) { navigationController?.pushViewController(vc, animated: true) } }
extension VKHomeViewCtrl:TYCyclePagerViewDataSource,TYCyclePagerViewDelegate{ func pagerViewTransformLayout(_ pagerViewTransformLayout: TYCyclePagerTransformLayout, initializeTransform attributes: UICollectionViewLayoutAttributes) { Log(message: "呵呵呵") }
func pagerViewTransformLayout(_ pagerViewTransformLayout: TYCyclePagerTransformLayout, applyTransformTo attributes: UICollectionViewLayoutAttributes) { Log(message: "哈哈哈") } func numberOfItems(in pageView: TYCyclePagerView) -> Int { return 1 } func pagerView(_ pagerView: TYCyclePagerView, cellForItemAt index: Int) -> UICollectionViewCell { let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "VKHomeCarouselCell", for: index)as!VKHomeCarouselCell cell.lab.text = String.init(format: "哈哈哈%d", index) return cell } func layout(for pageView: TYCyclePagerView) -> TYCyclePagerViewLayout { let layout = TYCyclePagerViewLayout.init() layout.itemSize = CGSize.init(width: ScreenWidth, height: 172 * kScreen) layout.itemHorizontalCenter = true return layout }
The text was updated successfully, but these errors were encountered:
问题解决了吗
Sorry, something went wrong.
No branches or pull requests
这里是全部代码
// HomeViewCtrl.swift
// VKIntlProperty
//
// Created by fox on 2021/2/3.
// Copyright © 2019 com.vk.TestP. All rights reserved.
//
import UIKit
class VKHomeViewCtrl: VKBaseViewCtrl {
}
//MARK: - UICollectionViewDataSource,UICollectionViewDelegate
extension VKHomeViewCtrl: UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UICollectionViewDelegate{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return dataArr.count
}
}
extension VKHomeViewCtrl:TYCyclePagerViewDataSource,TYCyclePagerViewDelegate{
func pagerViewTransformLayout(_ pagerViewTransformLayout: TYCyclePagerTransformLayout, initializeTransform attributes: UICollectionViewLayoutAttributes) {
Log(message: "呵呵呵")
}
}
The text was updated successfully, but these errors were encountered: