Day_Count_Memory_Days/anniversary_Project/Tool/AV_ScrollingScaleView.swift
2024-07-15 11:52:15 +08:00

52 lines
1.6 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// AV_ScrollingScaleView.swift
// anniversary_Project
//
// Created by 16 on 2024/7/8.
//
import UIKit
class AV_ScrollingScaleView: UIView {
private let scrollView = UIScrollView()
override init(frame: CGRect) {
super.init(frame: frame)
setupScrollView()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupScrollView()
}
private func setupScrollView() {
scrollView.frame = self.bounds
scrollView.backgroundColor = .white
self.addSubview(scrollView)
//
let contentWidth: CGFloat = 4000 // 20002
scrollView.contentSize = CGSize(width: contentWidth, height: self.bounds.height)
//
for i in 0...2000 {
let xPosition = CGFloat(i) * 2.0
let label = UILabel(frame: CGRect(x: xPosition, y: self.bounds.midY - 10, width: 50, height: 20))
label.text = "\(i)ml"
label.textColor = .black
label.textAlignment = .center
if i % 100 == 0 { // 100
label.font = UIFont.boldSystemFont(ofSize: 12)
label.frame = CGRect(x: xPosition, y: self.bounds.midY - 10, width: 50, height: 20)
} else {
label.font = UIFont.systemFont(ofSize: 10)
}
scrollView.addSubview(label)
}
}
}