Skip to content

Instantly share code, notes, and snippets.

@DonMag
Created February 15, 2018 18:56
Show Gist options
  • Select an option

  • Save DonMag/1d25b5fbd19c6f00b5f029a31bdeaf04 to your computer and use it in GitHub Desktop.

Select an option

Save DonMag/1d25b5fbd19c6f00b5f029a31bdeaf04 to your computer and use it in GitHub Desktop.
//
// Crash1hdViewController.swift
// temp
//
// Created by Don Mag on 2/15/18.
// Copyright © 2018 DonMag. All rights reserved.
//
import UIKit
class Crash1hdViewController: UIViewController {
let bkgView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
bkgView.translatesAutoresizingMaskIntoConstraints = false
bkgView.backgroundColor = .red
self.view.addSubview(bkgView)
bkgView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0.0).isActive = true
bkgView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0.0).isActive = true
bkgView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0.0).isActive = true
bkgView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0.0).isActive = true
let theLabel = UILabel()
theLabel.translatesAutoresizingMaskIntoConstraints = false
theLabel.backgroundColor = .yellow
theLabel.numberOfLines = 0
theLabel.textAlignment = .center
theLabel.text = "\nHello World!\n\n Tap anywhere to dismiss... \n"
bkgView.addSubview(theLabel)
theLabel.centerXAnchor.constraint(equalTo: bkgView.centerXAnchor, constant: 0.0).isActive = true
theLabel.centerYAnchor.constraint(equalTo: bkgView.centerYAnchor, constant: 0.0).isActive = true
// add a tap gesture
let tapRecognizer = UITapGestureRecognizer()
tapRecognizer.addTarget(self, action: #selector(onTap))
bkgView.addGestureRecognizer(tapRecognizer)
}
@objc func onTap() {
bkgView.isHidden = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment