I tried to create a UILabel
in playground but failed. Does playground only support OS X development for now?
But then what? Swift Playgrounds teaches concepts and uses real Swift structure, but it's not real code. It doesn't make an app, it just guides Byte around and solves puzzles. Swift doesn't have a real command called collectGem() after all.
Swift Playgrounds is a wonderful introduction to programming. It introduces imperative logic, functions, methods, loops, and many of the marvelous APIs that are available to iOS developers.
We can design and build standalone apps, but currently, there is no support for back-end capabilities.
YES, it does!
File: New > File... > iOS > Source > Playground
import UIKit let lbl = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 100)) lbl.text = "Hello StackOverflow!"
Then, save the file. (Or manually run it.) This will trigger the Playground to interpret UI related things. At this point, the word "UILabel" should appear on the right-hand side.
Now, to actually view what you've done, you've got to click on the "Quick View" eye on the right, or the white circle to open it in Assistant Editor:
Here's a screenshot of some basic things with UIImage working, etc.
(EDIT: minor text update to current CGRect syntax -- But, screenshots still show old syntax.)
Edited@2014-11-13: It seems the new xcode 6 had fixed this.
NO, It doesn't. But it's worth noting that you can import UIKit.
If you want to import UIKit you cound follow this:
then you could import UIKit or some module for iOS
ps. I try to create a UIImageView but it doesn't show the correct image on the right side. It seem worthless to import UIKit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With