-
Notifications
You must be signed in to change notification settings - Fork 0
/
CallSheetCastInfoCell.swift
110 lines (82 loc) · 3.5 KB
/
CallSheetCastInfoCell.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// CallSheetCastInfoCell.swift
// VistaBridge
//
// Created by 齐晴 on 16/10/25.
// Copyright © 2016年 GaryQi. All rights reserved.
//
import UIKit
class CallSheetCastInfoCell: UITableViewCell {
var labels : [UILabel] = []//按顺序依次为:["演员","角色","出发时间","梳妆时间","服装时间","进场时间","备注"]
var characterInfosAboutCallSheet : CharactersInfosAboutCallSheet?
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// 2.5K 2.5K 2K 2K 2K 2K 4K
let titles = ["演员","角色","出发时间","梳妆时间","服装时间","进场时间","备注"]
for title in titles {
let label = UILabel()
label.text = title
label.textAlignment = .center
label.font = UIFont(name: "PingFangTC-Medium", size: 15)
label.textColor = UIColor(red: 70/255, green: 78/255, blue: 80/255, alpha: 1)
label.numberOfLines = 0
labels.append(label)
contentView.addSubview(label)
}
}
func prepareCallSheetCastInfoCell() {
//所有的数据在这里录入,不考虑布局的问题
if let characterInfos = self.characterInfosAboutCallSheet {
labels[0].text = searchCharacterInfosByID(characterInfos.characterID)?.name
labels[1].text = searchCastInfosByID(characterInfos.characterID)
labels[2].text = characterInfos.departureTime
labels[3].text = characterInfos.makeupTime
labels[4].text = characterInfos.wardrobeTime
labels[5].text = characterInfos.setCallTime
labels[6].text = characterInfos.remarks
}
}
override func layoutSubviews() {
super.layoutSubviews()
let arr1 = [0,2.5,5,7,9,11,13] //计算相对位置的系数
let arr2 = [2.5,2.5,2,2,2,2,4] //计算宽度的系数
let referenceK = contentView.frame.size.width/17
let superviewHeight = contentView.frame.size.height
for i in 0...6 {
labels[i].frame.origin.x = 0 + referenceK * CGFloat(arr1[i])
// labels[i].frame.origin.y = (superviewHeight - )
labels[i].frame.size.width = referenceK * CGFloat(arr2[i])
labels[i].frame.size.height = contentView.frame.height
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
fileprivate func searchCharacterInfosByID(_ ID : Int) -> Character?{
if(ID < 200) {
for character in characters {
if character.ID == ID {
return character
}
}
} else {
//说明是群演
for character in backgroundCharacters {
if character.ID == ID {
return character
}
}
}
return nil
}
fileprivate func searchCastInfosByID(_ ID : Int) -> String? {
let character = searchCharacterInfosByID(ID)
let characterID = character?.ID
for cast in CAST {
if cast.characterID == characterID {
return cast.name
}
}
return nil
}
}