需要在UICollectionview Cell for Swift中使用View

时间:2017-11-18 03:08:21

标签: ios swift uicollectionview

StoryBoard Xib File

xib文件是

import Foundation
import UIKit

class DateSelectionView : UIView {

    @IBOutlet weak var month: UILabel!
    override init(frame: CGRect) {
      super.init(frame: frame)
      setUpViewSyle()
     }

   required init?(coder aDecoder: NSCoder) {
     super.init(coder : aDecoder)
     setUpViewSyle()
   }

   override func awakeFromNib() {

   }

  func setUpViewSyle() {
    self.backgroundColor = AppConfig.UI.themeColor
  } 

}

我需要在任何collectionView中使用这个xib文件,并更新循环中的月份和剩余标签,如下所示,

    let cell = dateCollectionView.dequeueReusableCell(withReuseIdentifier: 
      "DateSelectionCell", for: indexPath) as! DateSelectionViewCell

    cell.month.text = "Jan"

0 个答案:

没有答案