This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
TableViewCell.swift
62 lines (48 loc) · 1.62 KB
/
TableViewCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// TableViewCell.swift
// Coins
//
// Created by Sam Soffes on 11/25/14.
// Copyright (c) 2014 Nothing Magical, Inc. All rights reserved.
//
import UIKit
import CoinsKit
class TableViewCell: UITableViewCell {
// MARK: - Initializers
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .Value1, reuseIdentifier: reuseIdentifier)
textLabel?.font = UIFont(name: "Avenir-Heavy", size: 18)
textLabel?.textColor = UIColor(white: 0.4, alpha: 1)
textLabel?.highlightedTextColor = UIColor.whiteColor()
textLabel?.adjustsFontSizeToFitWidth = true
if let detailTextLabel = detailTextLabel {
detailTextLabel.font = UIFont(name: "Avenir-Book", size: 18)
detailTextLabel.textColor = UIColor(white: 0.4, alpha: 0.5)
detailTextLabel.highlightedTextColor = UIColor.whiteColor()
}
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
let background = UIView()
background.backgroundColor = UIColor(white: 1, alpha: 0.3)
backgroundView = background
}
let selected = UIView()
selected.backgroundColor = CoinsKit.blueColor
selectedBackgroundView = selected
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - UIView
override func layoutSubviews() {
super.layoutSubviews()
if let textLabel = textLabel {
var rect = textLabel.frame
rect.size.width = min(rect.size.width, 240)
textLabel.frame = rect
}
if let detailTextLabel = detailTextLabel {
let size = contentView.bounds.size
detailTextLabel.frame = CGRect(x: size.width - 70, y: 10, width: 60, height: size.height - 20)
}
}
}