Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import Foundation
  2.  
  3. import UIKit
  4.  
  5. class MySampleView :UIView{
  6. override init(frame: CGRect) {
  7. super.init(frame: frame)
  8. self.backgroundColor = UIColor.blue
  9. }
  10.  
  11. required init?(coder aDecoder: NSCoder) {
  12. fatalError("init(coder:) has not been implemented")
  13. }
  14. }
  15.  
  16. @UIApplicationMain
  17. class AppDelegate: UIResponder, UIApplicationDelegate {
  18. var window: UIWindow?
  19. var bridge: RCTBridge!
  20.  
  21. func application(
  22. _ application: UIApplication,
  23. didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  24. ) -> Bool {
  25. let rootViewController = UIViewController()
  26.  
  27.  
  28. // Create ReactNativeView as root
  29. // let rootView = createRNView(didFinishLaunchingWithOptions: launchOptions)
  30.  
  31. // Create iOS UIView as root
  32. let rootView = createUIView(frame: UIScreen.main.bounds)
  33. rootViewController.view = rootView
  34.  
  35. let window = UIWindow(frame: UIScreen.main.bounds)
  36. window.rootViewController = rootViewController
  37. window.makeKeyAndVisible()
  38. self.window = window
  39.  
  40. return true
  41. }
  42.  
  43.  
  44. func createRNView(
  45. didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  46. ) -> UIView {
  47. let jsCodeLocation = RCTBundleURLProvider
  48. .sharedSettings()
  49. .jsBundleURL(
  50. forBundleRoot: "index.ios",
  51. fallbackResource:nil)
  52.  
  53. let rootView = RCTRootView(
  54. bundleURL: jsCodeLocation,
  55. moduleName: "mynativeejectapp",
  56. initialProperties: nil,
  57. launchOptions: launchOptions
  58. )
  59. return rootView!
  60. }
  61.  
  62. func createUIView(frame: CGRect) -> UIView {
  63. return MySampleView(frame: frame)
  64. }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement