This file contains 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
import Cocoa | |
class ContainerView: ColorView {} | |
class ColorView: NSView { | |
required init(frame: CGRect, color: NSColor) { | |
super.init(frame: frame) | |
wantsLayer = true | |
layer?.backgroundColor = color.cgColor | |
} |
This file contains 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
import Cocoa | |
let label = NSTextField() | |
label.frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 44)) | |
label.stringValue = "My awesome label" | |
label.backgroundColor = .white | |
label.isBezeled = false | |
label.isEditable = false | |
label.sizeToFit() |
This file contains 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
import UIKit | |
let label = UILabel() | |
label.frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 44)) | |
label.text = "My awesome label" | |
label.backgroundColor = .white | |
label.sizeToFit() |
This file contains 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
import Cocoa | |
class MyViewController: NSViewController { | |
override func loadView() { | |
self.view = NSView() | |
} | |
} | |
let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
let viewController = MyViewController() |
This file contains 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
import Cocoa | |
class MyViewController: NSViewController {} | |
let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
let viewController = MyViewController() | |
viewController.view.frame = frame |
This file contains 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
import UIKit | |
class MyViewController: UIViewController {} | |
let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
let viewController = MyViewController() | |
viewController.view.frame = frame |
This file contains 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
import Cocoa | |
let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
let view = NSView(frame: frame) | |
view.wantsLayer = true | |
view.layer?.backgroundColor = NSColor.blue.cgColor |
This file contains 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
import UIKit | |
let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) | |
let view = UIView(frame: frame) | |
view.backgroundColor = UIColor.blue |
This file contains 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
let familyController = FamilyViewController() | |
let customController = CustomViewController() | |
familyController.addChildViewController(customController, view: { $0.scrollView }) |
This file contains 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
let familyController = FamilyViewController() | |
let viewController = UIViewController() | |
familyController.addChildViewController(viewController, height: 175) |