Pārlūkot izejas kodu

Add Playground Sample (#608)

Shiva Huang 6 gadi atpakaļ
vecāks
revīzija
df9df818dd

+ 7 - 0
README.md

@@ -114,6 +114,13 @@ class MyViewController: UIViewController {
 }
 ```
 
+### Playground
+You can try SnapKit in Playground.
+
+**Note:**
+
+> To try SnapKit in playground, open `SnapKit.xcworkspace` and build SnapKit.framework for any simulator first.
+
 ### Resources
 
 - [Documentation](http://snapkit.io/docs/)

+ 3 - 0
SnapKit.xcworkspace/contents.xcworkspacedata

@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Workspace
    version = "1.0">
+   <FileRef
+      location = "group:SnapKitPlayground.playground">
+   </FileRef>
    <FileRef
       location = "container:SnapKit.xcodeproj">
    </FileRef>

+ 8 - 0
SnapKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IDEDidComputeMac32BitWarning</key>
+	<true/>
+</dict>
+</plist>

+ 29 - 0
SnapKitPlayground.playground/Contents.swift

@@ -0,0 +1,29 @@
+//: A UIKit based Playground for presenting user interface
+// To use this playground, build SnapKit.framework for any simulator first.
+
+import SnapKit
+import UIKit
+import PlaygroundSupport
+
+class MyViewController : UIViewController {
+    override func loadView() {
+        let view = UIView()
+        view.backgroundColor = .white
+
+        let label = UILabel()
+        label.text = "Hello World!"
+        label.textColor = .black
+        
+        view.addSubview(label)
+
+        label.snp.makeConstraints { (make) in
+            make.left.equalToSuperview().offset(150)
+            make.top.equalToSuperview().offset(200)
+            make.size.equalTo(CGSize(width: 200, height: 20))
+        }
+
+        self.view = view
+    }
+}
+// Present the view controller in the Live View window
+PlaygroundPage.current.liveView = MyViewController()

+ 4 - 0
SnapKitPlayground.playground/contents.xcplayground

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<playground version='5.0' target-platform='ios' executeOnSourceChanges='true'>
+    <timeline fileName='timeline.xctimeline'/>
+</playground>

+ 6 - 0
SnapKitPlayground.playground/timeline.xctimeline

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Timeline
+   version = "3.0">
+   <TimelineItems>
+   </TimelineItems>
+</Timeline>