-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLicenseCell.swift
42 lines (38 loc) · 1.65 KB
/
LicenseCell.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
//
// LicenseCell.swift
// Real News
//
// Created by PC on 4/19/17.
// Copyright © 2017 PC. All rights reserved.
//
import Foundation
import UIKit
class LicenseCell:UITableViewCell{
let name = UILabel()
let content = UILabel()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
backgroundColor = UIColor.clear
contentView.backgroundColor = UIColor.clear
separatorInset = UIEdgeInsetsMake(0, padding.totalTextHorizontal.rawValue, 0, padding.totalTextHorizontal.rawValue)
name.lineBreakMode = NSLineBreakMode.byWordWrapping
name.numberOfLines = 0
name.backgroundColor = UIColor.clear
content.backgroundColor = UIColor.clear
content.lineBreakMode = .byWordWrapping
content.numberOfLines = 0
contentView.addSubview(name)
contentView.addSubview(content)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func layoutSubviews() {
super.layoutSubviews()
let size = CGSize(width: contentView.bounds.width - padding.totalTextHorizontal.rawValue*2, height: .greatestFiniteMagnitude)
let nameSize = name.sizeThatFits(size)
let contentSize = content.sizeThatFits(size)
name.frame = CGRect(x: padding.totalTextHorizontal.rawValue, y: padding.totalTextHorizontal.rawValue, width: nameSize.width, height: nameSize.height)
content.frame = CGRect(x: padding.totalTextHorizontal.rawValue, y: name.frame.maxY + padding.interLabel.rawValue, width: contentSize.width, height: contentSize.height)
}
}