CNUpSlideDetailScrollView.swift
3.05 KB
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
//
// CNUpSlideDetailScrollView.swift
// metaCode
//
// Created by zx on 2023/10/16.
//
import UIKit
class CNUpSlideDetailScrollView: UIScrollView {
let bgBackView = UIView()
let imageView = UIImageView()
let textView = UITextView()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
bgBackView.frame = CGRect(x: 0, y: 0, width: KSreenWidth, height: GlobalConstants.cardDetailTopImageH)
bgBackView.layer.masksToBounds = true
imageView.frame = bgBackView.bounds
imageView.isUserInteractionEnabled = true
imageView.contentMode = .scaleAspectFill
let textViewWidth = KSreenWidth - 2 * textViewLeftMargin
let font = UIFont.boldSystemFont(ofSize: 15)
let textHeight = textViewText.calculateHeightWith(width: textViewWidth, font: font)
textView.frame = CGRect(x: textViewLeftMargin, y: bgBackView.frame.height + textViewTopMargin, width: textViewWidth, height: textHeight + textViewBottomMargin)
textView.text = textViewText
textView.font = font
textView.textColor = .gray
bgBackView.addSubview(imageView)
addSubview(bgBackView)
addSubview(textView)
contentSize = CGSize(width: KSreenWidth, height: bgBackView.frame.height + textViewTopMargin + textView.frame.height + textViewBottomMargin)
}
}
fileprivate let textViewLeftMargin: CGFloat = 20
fileprivate let textViewTopMargin: CGFloat = 40
fileprivate let textViewBottomMargin: CGFloat = 50
fileprivate let textViewText = "Thank you. I'm honored to be with you today for your commencement from one of the finest universities in the world. Truth be told, i never graduated from college and this is the closest I've ever gotten to a college gradution. \n\nToday i want to tell you three stories from my life. That's it. No big deal. Just three stories. The first story is about connecting the dots. \n\ndropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out? \n\nIt started before I was born. My biological mother was a young,unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: 'We got an unexpected baby boy; do you want him?' They said: 'Of course.' My biological mother found out later that my mother had never graduated from college and my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would go to college."