Skip to content

Commit c6aa9ef

Browse files
Update README
1 parent c0e31fa commit c6aa9ef

1 file changed

Lines changed: 55 additions & 2 deletions

File tree

README.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,56 @@ JavaScriptBridge provides the way to write iOS apps with JavaScript.
88

99
## Usage
1010

11-
To run the example project; clone the repo, and run `pod install` from the Project directory first.
11+
###Hello world on JavaScriptBridge
12+
13+
This is the most simple way.
14+
15+
```objc
16+
@implementation JSBAppDelegate
17+
18+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
19+
{
20+
JSContext *context = [JSBScriptingSupport globalContext];
21+
22+
[context evaluateScript:
23+
@"var window = UIWindow.new();"
24+
@"window.frame = UIScreen.mainScreen().bounds;"
25+
@"window.backgroundColor = UIColor.whiteColor();"
26+
@""
27+
@"var navigationController = UINavigationController.new();"
28+
@"var viewController = UIViewController.new();"
29+
@"viewController.navigationItem.title = 'Make UI with JavaScript';"
30+
@""
31+
@"var view = UIView.new();"
32+
@"view.backgroundColor = UIColor.redColor();"
33+
@"view.frame = {x: 20, y: 80, width: 280, height: 80};"
34+
@""
35+
@"var label = UILabel.new();"
36+
@"label.backgroundColor = UIColor.blueColor();"
37+
@"label.textColor = UIColor.whiteColor();"
38+
@"label.text = 'Hello World.';"
39+
@"label.font = UIFont.boldSystemFontOfSize(24);"
40+
@"label.sizeToFit();"
41+
@""
42+
@"var frame = label.frame;"
43+
@"frame.x = 10;"
44+
@"frame.y = 10;"
45+
@"label.frame = frame;"
46+
@""
47+
@"view.addSubview(label);"
48+
@"viewController.view.addSubview(view);"
49+
@""
50+
@"navigationController.viewControllers = [viewController];"
51+
@""
52+
@"window.rootViewController = navigationController;"
53+
@"window.makeKeyAndVisible();"
54+
];
55+
56+
return YES;
57+
}
58+
59+
@end
60+
```
1261
1362
## Requirements
1463
**iOS 7 or later**
@@ -26,5 +75,9 @@ kishikawa katsumi, [email protected]
2675
2776
## License
2877
29-
JavaScriptBridge is available under the MIT license. See the LICENSE file for more info.
78+
[Apache]: http://www.apache.org/licenses/LICENSE-2.0
79+
[MIT]: http://www.opensource.org/licenses/mit-license.php
80+
[GPL]: http://www.gnu.org/licenses/gpl.html
81+
[BSD]: http://opensource.org/licenses/bsd-license.php
3082
83+
JavaScriptBridge is available under the [MIT license][MIT]. See the LICENSE file for more info.

0 commit comments

Comments
 (0)