swift----纯代码实现 UITableViewCell单元格的自定义

来源:互联网 发布:python中range 函数 编辑:程序博客网 时间:2024/05/16 07:50


import UIKit

class bar1TableViewCell:UITableViewCell {

 
   
@IBOutletvar view:UIView!
   
   
@IBOutletweakvar headingType:UILabel!
   
   
@IBOutletweakvar headingContent:UILabel!
   
   
@IBOutletweakvar codeName:UILabel!
   
   
@IBOutletweakvar percentage:UILabel!
   
   
   
@IBOutletweakvar moneyCount:UILabel!

   
@IBOutletweakvar dayCount:UILabel!
   
   
@IBOutletweakvar surplus:UILabel!
   
   
 
   
//   
//    swift
2种构造器:指定构造器 designated init 便利构造器 convenience initconvenience init必须最终调用类中某个designated init
//   
//    init(style: UITableViewCellStyle, reuseIdentifier: String?)
是便利构造器,所以要调用指定构造器 init(coder aDecoder: NSCoder)
//   
   
   
requiredinit(coder aDecoder:NSCoder) {
       
super.init(coder: aDecoder)!
       
print("1")
       
       
let uiview=UIView()
       
           uiview.
frame=CGRectMake(0,0,self.bounds.width,100)
       
               
//self.backgroundColor=UIColor.blackColor()
       
                uiview.
backgroundColor=UIColor.blackColor()
               
self.addSubview(uiview)
       
    }

0 1
原创粉丝点击