Image - Tai-Kimura/SwiftJsonUI GitHub Wiki

Image

class: SJUIImageView
inherites: UIImageView
child classes: NetworkImageView

Platform Support

  • UIKit: Full support (All attributes available)
  • SwiftUI: Full support (All attributes available through DynamicComponent)
  • Jetpack Compose: Full support (Maps to Image/AsyncImage composables)
  • Android XML: Maps to ImageView
    • NetworkImage → com.kotlinjsonui.views.KjuiNetworkImageView
    • CircleImage → com.kotlinjsonui.views.KjuiCircleImageView

Attributes for Image

attribute name UIKit SwiftUI Compose XML type in json details remarks
src string Name of image you want to set to the imageView
contentMode string Content mode: AspectFill, AspectFit, Center, ScaleToFill, Top, Bottom, Left, Right
canTap boolean Enable tap capability
onclick string Selector-based tap event handler

Properties for Image

Static Properties

open class var viewClass: SJUIImageView.Type

This property will be used to decide which class to inflate with createFromJSON method. You should define the view's class on this property when you create classes inheriting from SJUIImageView.

Instance Properties

public var canTap: Bool

Whether the image view can be tapped and respond to touch events. Default is false. When set to true, enables touch handling and gesture recognition.

internal var filter: SJUIView?

Internal filter view used for touch handling and visual effects. Automatically managed by the touch handling system.

Inherited Properties

SJUIImageView inherits all properties from UIImageView and SJUIView, including:

  • Image display properties (image, highlightedImage, etc.)
  • Content mode and scaling options
  • Touch and gesture handling from SJUIView
  • Layout constraint management
  • Visibility and styling properties

Functions for Image

Static Methods

public class func createFromJSON(attr: JSON, target: Any, views: inout [String: UIView]) -> SJUIImageView

Factory method called when the image view is created from JSON file.
Override this method when you create classes inheriting from SJUIImageView class.

Instance Methods

func setMask()

Sets up internal touch handling mask for proper touch event processing. Automatically called when touch handling is enabled.

Override Methods

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?)
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?)
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)

Touch handling methods that manage tap events and visual feedback. Only active when canTap is set to true.

@objc override func onBeginTap()
@objc override func onEndTap()

Custom touch begin and end handling inherited from SJUIView. Provides visual feedback during touch interactions.

Event Handling

SJUIImageView supports touch events through:

  • The canTap property to enable/disable touch handling
  • Integration with SJUIView's touch handling system
  • Support for onclick events via JSON configuration
  • Gesture recognizer support through inherited functionality
⚠️ **GitHub.com Fallback** ⚠️