Skip to content

Instantly share code, notes, and snippets.

@wiwi-git
Created November 30, 2020 09:55
Show Gist options
  • Save wiwi-git/84ebad3f61eb1e2d6dba922331252692 to your computer and use it in GitHub Desktop.
Save wiwi-git/84ebad3f61eb1e2d6dba922331252692 to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
var loadings = UIView()
var loadingView:LoadingView?
var imageUrls:[URL?] = []
override func viewDidLoad() {
super.viewDidLoad()
loadingsSetting()
startButtonSetting()
imageUrls.append(Bundle.main.url(forResource: "emoticon", withExtension: "png"))
imageUrls.append(Bundle.main.url(forResource: "ac", withExtension: "png"))
imageUrls.append(Bundle.main.url(forResource: "emoji", withExtension: "png"))
imageUrls.append(Bundle.main.url(forResource: "mail", withExtension: "png"))
imageUrls.append(Bundle.main.url(forResource: "adb", withExtension: "png"))
}
func loadingsSetting() {
self.view.addSubview(loadings)
loadings.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
let safe = self.view.safeAreaLayoutGuide
loadings.snp.makeConstraints { (make) in
make.leading.trailing.equalTo(safe)
make.centerY.equalTo(self.view)
make.height.equalTo(200)
}
loadings.backgroundColor = .red
self.loadingView = LoadingView(frame: self.loadings.bounds)
self.loadingView?.backgroundColor = UIColor.init(displayP3Red: 0.5, green: 0.5, blue: 0.5, alpha: 0.5)
self.loadings.addSubview(loadingView!)
loadingView?.snp.makeConstraints({ (make) in
make.top.leading.equalToSuperview().offset(10)
make.bottom.trailing.equalToSuperview().offset(-10)
})
}
func startButtonSetting() {
let button = UIButton()
self.view.addSubview(button)
button.frame = CGRect(x: 0, y: 0, width: 50, height: 50)
button.snp.makeConstraints { (make) in
make.top.equalTo(self.view.safeAreaLayoutGuide).offset(10)
make.leading.equalToSuperview().offset(10)
make.trailing.equalToSuperview().offset(-10)
make.height.equalTo(40)
}
button.backgroundColor = .clear
button.layer.borderWidth = 1
button.layer.borderColor = UIColor.black.cgColor
button.layer.cornerRadius = 10
button.setTitle("Start", for: .normal)
button.setTitleColor(.black, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 20)
button.addTarget(self, action: #selector(touchUpStartButtonAction), for: .touchUpInside)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment