Develop your own functions

Define in a class the function that you want to use for a Your element. Please note that the function name is also set in the same notation in the contentDock Management System for the respective Your Element. How you set the function names is up to you. But we recommend to follow the standard Code Guidlines.

Example
import UIKit
import CDockFramework

@objc(CustomElementsFunctionsSwift)

class CustomElementsFunctionsSwift: NSObject {
 
    @objc class func myElementFunction(_ elementView: UIView) {
        elementView.backgroundColor = .white
        
        let label = UILabel()
        label.text = "Hello world!"

        elementView.addSubview(label)
    }
}

As parameter you get a standard UIView object. For more information, see Apple Developer Documentation | UIView Class.


Include other code libraries

You can include other code libraries from other vendors and use them for your functions.

Include LTMorphingLabel
import UIKit
import LTMorphingLabel
import CDockFramework

@objc(CustomElementsFunctionsSwift)

class CustomElementsFunctionsSwift: NSObject {

    @objc class func myElementFunction(_ elementView: UIView) {
        elementView.backgroundColor = .black;

        let label = LTMorphingLabel()
        label.translatesAutoresizingMaskIntoConstraints = false
        label.textColor = .white
        label.font = UIFont.systemFont(ofSize: 28, weight: .bold)
        label.text = "Hello World!"
        label.morphingEffect  = .pixelate
        elementView.addSubview(label)
    }

}

Example with LTMorphingLabel


More information


Feedback or Questions

We are always happy to help you with questions about the code or other questions.

Was this page helpful? Yes No

Topics on this page