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

  1. Open .page file
  2. Add platform widget on the page
  1. Include ScadeExtension library: https://docs.scade.io/docs/scadeextensions-library
  2. 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.