-
Create single view swift app
-
Remove storyboard file & clear ""Main Interface" field in App/Tragets configuration
-
Remove Scene delegate and other scene files From Info.plist, remove whole "Application Scene Manifest" entry
Last active
January 14, 2020 22:48
-
-
Save mfyz/329004518861d702f6d9ec0bc878897b to your computer and use it in GitHub Desktop.
Bare bones swift iOS app (without storyboard and scenes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
window = UIWindow(frame: UIScreen.main.bounds) | |
let homeViewController = UIViewController() | |
homeViewController.view.backgroundColor = UIColor.red | |
window!.rootViewController = homeViewController | |
window!.makeKeyAndVisible() | |
/* | |
With navigation controller | |
let homeViewController = HomeViewController() | |
let navigation = UINavigationController(rootViewController: homeViewController) | |
window!.rootViewController = navigation | |
window!.makeKeyAndVisible() | |
*/ | |
return true | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple VC code builds UI with plain animation | |
import UIKit | |
class HomeViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.navigationController?.isNavigationBarHidden = false | |
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(startRecording)) | |
// Build screen layout | |
self.view.backgroundColor = .white | |
let btn = UIButton(type:.system) | |
btn.backgroundColor = .blue | |
btn.setTitle("Button", for: .normal) | |
btn.tintColor = .white | |
btn.layer.cornerRadius = 5 | |
btn.frame = CGRect(x: 50, y: 150, width: 100, height: 40) | |
UIView.animate(withDuration: 10.0, animations: { | |
btn.frame = CGRect(x: 50, y: 700, width: 100, height: 40) | |
}) | |
self.view.addSubview(btn) | |
/* | |
currentAnswer = UITextField() | |
currentAnswer.translatesAutoresizingMaskIntoConstraints = false | |
currentAnswer.placeholder = "Tap letters to guess" | |
currentAnswer.textAlignment = .center | |
currentAnswer.font = UIFont.systemFont(ofSize: 44) | |
currentAnswer.isUserInteractionEnabled = false | |
view.addSubview(currentAnswer) | |
*/ | |
/* | |
scoreLabel = UILabel() | |
scoreLabel.translatesAutoresizingMaskIntoConstraints = false | |
scoreLabel.textAlignment = .right | |
scoreLabel.text = "Score: 0" | |
view.addSubview(scoreLabel) | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment