LoginSignup
43
32

More than 5 years have passed since last update.

StoryBoardを使わないでプロジェクト作成(Xcode8,Swift3)

Last updated at Posted at 2016-11-25

swift3で新規アプリを作ることになったので備忘録です。

他の備忘録
- StoryBoardを使わないでプロジェクト作成(Xcode8,Swift3)
- アプリ開発でdebug/staging/release環境があるならbundleは3種類あったほうが捗る
- Staging用の環境設定をXcodeに追加する
- 設定画面をコードだけで書く時いつも悩む

手順

  1. プロジェクト作成
  2. 「Main.storyboard」を削除
  3. 「Info.plist」の「Main storyboard file base name」を「Main」→なし
  4. 「AppDelegate.swift」にビューを定義する

1. プロジェクト作成

中身の設定はお好みでどうぞ
スクリーンショット 2016-11-25 19.43.40.png

2. 「Main.storyboard」を削除

「Move to Trash」で豪快に消しちゃいます
スクリーンショット 2016-11-25 19.51.18.png

3. 「Info.plist」の「Main storyboard file base name」を「Main」→なし

スクリーンショット 2016-11-25 19.50.29.png

4. 「AppDelegate.swift」にビューを定義する

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    self.window = UIWindow(frame: UIScreen.main.bounds)
    self.window?.rootViewController = ViewController()
    self.window?.makeKeyAndVisible()

    return true
}

このまま動きますが、動かしても真っ黒でつまらないので、ViewControllerに以下を追加

override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor.red // 背景を赤に
}

できあがり

スクリーンショット 2016-11-25 20.11.56.png

43
32
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
43
32