Platform control
Introduction
Platform widget is used for access to the native iOS/macOS/Android API:
iOS:
https://developer.apple.com/documentation/uikit/uiview
macOS:
https://developer.apple.com/documentation/appkit/nsview
Android: coming soon
How to use
- Open .page file
- Add platform widget on the page
- Include ScadeExtension library: https://docs.scade.io/docs/scadeextensions-library
- Use macOS platformView.nsView and iOS platformView.uiView
Code example:
import ScadeKit
import ScadeUI
class MainPageAdapter: SCDLatticePageAdapter {
#if os(iOS)
@objc func buttonAction(sender: UIButton!) {
let id = sender.tag
print(id)
}
#endif
// page adapter initialization
override func load(_ path: String) {
super.load(path)
#if os(macOS)
if let view = self.platformView.nsView {
view.wantsLayer = true
view.layer?.backgroundColor = NSColor.blue.cgColor
}
#elseif os(iOS)
if let view = self.platformView.uiView {
let button = UIButton(frame: CGRect(x: 20, y: 20, width: 200, height: 60))
button.setTitle("Native button", for: .normal)
button.setTitleColor(UIColor.black, for: .normal)
button.layer.borderWidth = 2
button.addTarget(self, action: #selector(buttonAction), for: .touchUpInside)
view.addSubview(button)
}
#endif
}
}
Support for Android coming soon.
Updated almost 3 years ago