Created
May 29, 2019 00:08
-
-
Save SatoTakeshiX/67e1b5aa5d4b5dbbce14f11b871a9f2e to your computer and use it in GitHub Desktop.
UIView convert method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
class MyViewController : UIViewController { | |
override func loadView() { | |
let view = UIView() | |
view.backgroundColor = UIColor.blue | |
let label = UILabel() | |
label.frame = CGRect(x: 150, y: 200, width: 200, height: 20) | |
label.text = "Hello World!" | |
label.textColor = .black | |
view.addSubview(label) | |
let topView = UIView() | |
topView.frame = CGRect(x: 0, y: 0, width: 300, height: 240) | |
topView.backgroundColor = .red | |
view.addSubview(topView) | |
let bottomView = UIView() | |
bottomView.frame = CGRect(x: 0, y:topView.frame.height, width: 300, height: 240) | |
bottomView.backgroundColor = .green | |
view.addSubview(bottomView) | |
convert(top: topView, bottom: bottomView) | |
self.view = view | |
} | |
private func convert(top: UIView, bottom: UIView) -> CGRect { | |
return CGRect() | |
} | |
} | |
// Present the view controller in the Live View window | |
PlaygroundPage.current.liveView = MyViewController() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment