问题
I'm trying to create a UIView in Swift Playground (in Xcode). My goal is to create the largest possible view. The current size is 1024 x 768. And if I try to increase the width or height, the view (when played in Live View) actually gets smaller which I think is happening so that it scales down to the window. But when I look at the Live View on 15-inch Macbook, there's a lot of space in the Live View -- the width can be increased, but I don't know how to increase it such that it actually takes up the entire screen.
Is there anyway to set the width to "full-screen"?
My code:
public class thisIsRandom: UIView {
override public init(frame: CGRect) {
super.init(frame: CGRect(x: 0, y: 0, width: 1024, height: 768))
self.backgroundColor = .black
}
}
回答1:
PlaygroundLiveViewRepresentation support size as per your screen display. I have MacBook Air 13 inch.
I have running live view in playground with 2048x1024 size, this show me large. This means it will show exactly on your screen size.
If same code will run in MacBook pro then it will smaller view, But, Also if your run this same code in iMac then it will display very small size of live view.
So, live view display on your MacBook, iMac screens size. I hope this will helpful to you.
来源:https://stackoverflow.com/questions/49433756/what-is-the-largest-possible-size-of-a-uiview-in-a-swift-playground