//
// LimitCell.swift
// loveLimitedFree
//
// Created by 鄧江洲 on 16/8/4.
// Copyright ? 2016年 鄧江洲. All rights reserved.
//
import UIKit
class LimitCell: UITableViewCell {
var backgroundImageView: UIImageView?
var iconImageView: UIImageView?
var nameLabel: UILabel?
var timeLabel: UILabel?
var originalPriceLabel: UILabel?
var starView: StarView? //MARK:- hehe
var categoryLabel: UILabel?
var shareLabel: UILabel?
var favouriteLabel: UILabel?
var downloadLabel: UILabel?
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.backgroundImageView = UIImageView(frame: CGRectMake(0, 0, 375, 100))
self.contentView.addSubview(self.backgroundImageView!)
self.iconImageView = UIImageView(frame: CGRectMake(20, 10, 60, 60))
self.contentView.addSubview(self.iconImageView!)
self.nameLabel = UILabel(frame: CGRectMake(100,4,200,20))
self.contentView.addSubview(self.nameLabel!)
self.timeLabel = UILabel(frame: CGRectMake(100,28,150,20))
self.contentView.addSubview(self.timeLabel!)
self.originalPriceLabel = UILabel(frame: CGRectMake(260,28,100,20))
self.contentView.addSubview(self.originalPriceLabel!)
self.starView = StarView(frame: CGRectMake(100, 50, 65, 23))
self.contentView.addSubview(self.starView!)
self.categoryLabel = UILabel(frame: CGRectMake(240,52,100,20))
self.contentView.addSubview(self.categoryLabel!)
self.categoryLabel?.layer.borderColor = UIColor.cyanColor().CGColor
self.categoryLabel?.layer.borderWidth = 2
self.categoryLabel?.textAlignment = .Center
self.shareLabel = UILabel(frame: CGRectMake(20,76,100,20))
self.contentView.addSubview(self.shareLabel!)
self.favouriteLabel = UILabel(frame: CGRectMake(130,76,100,20))
self.contentView.addSubview(self.favouriteLabel!)
self.downloadLabel = UILabel(frame: CGRectMake(240,76,100,20))
self.contentView.addSubview(self.downloadLabel!)
}
func configurationMessageByModel(model: LimitModel, atIndex index: Int, deleteToTheLength cutTimeIndex: Int){
if index%3 == 1 {
self.backgroundImageView?.image = UIImage(named: "cate_list_bg1")
}else if index%3 == 2{
self.backgroundImageView?.image = UIImage(named: "cate_list_bg2")
}else {
self.backgroundImageView?.image = nil
}
let iconUrl = NSURL(string: model.iconUrl!)
self.iconImageView?.kf_setImageWithURL(iconUrl)
self.nameLabel?.text = "\(index+1). \(model.name!)"
self.categoryLabel?.text = Util.transferCateName(model.categoryName!)
let priceString = "¥: \(model.lastPrice!)"
let priceAttributedString = NSAttributedString(string: priceString, attributes: [NSStrikethroughStyleAttributeName: 2, NSStrikethroughColorAttributeName: UIColor.redColor()])
self.originalPriceLabel?.attributedText = priceAttributedString
let rate = NSString(string: model.starCurrent!).floatValue
self.starView?.setStars(CGFloat(rate))
let timeTextIndex = model.expireDatetime?.endIndex.advancedBy(-cutTimeIndex)
let timeString = model.expireDatetime?.substringToIndex(timeTextIndex!)
let dateFormat = NSDateFormatter()
//2016-08-05 00:58:35.0
dateFormat.dateFormat = "yyyy-MM-dd HH:mm:ss"
let expireTime = dateFormat.dateFromString(timeString!)//很明顯的 正則表達(dá)式)
let carlendar = NSCalendar.currentCalendar()
let unitFlags = NSCalendarUnit(rawValue: NSCalendarUnit.Hour.rawValue | NSCalendarUnit.Minute.rawValue | NSCalendarUnit.Second.rawValue )
let dateTimeNeeds = carlendar.components(unitFlags, fromDate: NSDate(), toDate: expireTime!, options: NSCalendarOptions(rawValue: 0) )
self.timeLabel?.text = String(format: "剩余 %2d: %02d: %02d .", dateTimeNeeds.hour, dateTimeNeeds.minute, dateTimeNeeds.second)
self.shareLabel?.text = "分享 \(model.shares!)次"
self.favouriteLabel?.text = "收藏 \(model.favorites!)次"
self.downloadLabel?.text = "下載 \(model.downloads!)次"
}
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
}
}
Cell: 用代碼創(chuàng)建
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門麸澜,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人奏黑,你說(shuō)我怎么就攤上這事炊邦。” “怎么了攀涵?”我有些...
- 文/不壞的土叔 我叫張陵铣耘,是天一觀的道長(zhǎng)洽沟。 經(jīng)常有香客問(wèn)我以故,道長(zhǎng),這世上最難降的妖魔是什么裆操? 我笑而不...
- 正文 為了忘掉前任怒详,我火速辦了婚禮炉媒,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘昆烁。我一直安慰自己吊骤,他們只是感情好,可當(dāng)我...
- 文/花漫 我一把揭開(kāi)白布静尼。 她就那樣靜靜地躺著白粉,像睡著了一般。 火紅的嫁衣襯著肌膚如雪鼠渺。 梳的紋絲不亂的頭發(fā)上鸭巴,一...
- 那天,我揣著相機(jī)與錄音拦盹,去河邊找鬼鹃祖。 笑死,一個(gè)胖子當(dāng)著我的面吹牛普舆,可吹牛的內(nèi)容都是我干的恬口。 我是一名探鬼主播,決...
- 文/蒼蘭香墨 我猛地睜開(kāi)眼沼侣,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼祖能!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起蛾洛,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤芯杀,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后雅潭,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體揭厚,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年扶供,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了筛圆。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站笋敞,受9級(jí)特大地震影響碱蒙,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一赛惩、第九天 我趴在偏房一處隱蔽的房頂上張望哀墓。 院中可真熱鬧,春花似錦喷兼、人聲如沸篮绰。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)吠各。三九已至,卻和暖如春勉抓,著一層夾襖步出監(jiān)牢的瞬間走孽,已是汗流浹背。 一陣腳步聲響...
- 正文 我出身青樓念逞,卻偏偏與公主長(zhǎng)得像困食,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子翎承,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 最近有個(gè)需求是這樣的: cell上有標(biāo)題和一個(gè)按鈕叨咖,當(dāng)不需要按鈕顯示的時(shí)候瘩例,標(biāo)題label要和cell等寬,這個(gè)界...
- http://blog.csdn.net/syg90178aw/article/details/46981277
- 要求是圖片為正方形甸各,圖片下面是標(biāo)題和其它的內(nèi)容垛贤,我這里圖片和文字都寫(xiě)給的固定的值做完后的效果是這樣的: 流布局UI...
- 用了一天時(shí)間看完了貝爾格里爾斯寫(xiě)的《本能》這本書(shū)。書(shū)中寫(xiě)了貝爾的經(jīng)歷和遭遇到的困境以及戰(zhàn)勝困境改變命運(yùn)的力量趣倾。 開(kāi)...