Image - Tai-Kimura/SwiftJsonUI GitHub Wiki
class: SJUIImageView
inherites: UIImageView
child classes: NetworkImageView
- ✅ 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
- NetworkImage →
| 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 |
open class var viewClass: SJUIImageView.TypeThis 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.
public var canTap: BoolWhether 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.
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
public class func createFromJSON(attr: JSON, target: Any, views: inout [String: UIView]) -> SJUIImageViewFactory method called when the image view is created from JSON file.
Override this method when you create classes inheriting from SJUIImageView class.
func setMask()Sets up internal touch handling mask for proper touch event processing. Automatically called when touch handling is enabled.
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.
SJUIImageView supports touch events through:
- The
canTapproperty 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