用 Javascript 来编写 iOS 应用:JavaScriptBridge

jopen 11年前

JavaScriptBridge 能让用户完全或者部分使用 Javascript 来编写 iOS 应用,是 Cocoa 和 JavaScriptCore 的桥梁。

#import <JavaScriptBridge/JavaScriptBridge.h>  ...    // Retrieve the prepared context  JSContext *context = [JSBScriptingSupport globalContext];    // Add framework support if needed.  // ('Foundation', 'UIKit', 'QuartzCore' enabled by default.)  [context addScriptingSupport:@"MapKit"];  [context addScriptingSupport:@"MessageUI"];    // Evaluate script  [context evaluateScript:   @"var window = UIWindow.new();"   @"window.frame = UIScreen.mainScreen().bounds;"   @"window.backgroundColor = UIColor.whiteColor();"   @"window.makeKeyAndVisible();"  ];

项目主页:http://www.open-open.com/lib/view/home/1390398823914