PROTOCOL
UIStylableThemeDelegate
public protocol UIStylableThemeDelegate: AnyObject
The UI Stylable Theme delegate defines the callback interface for UIViewControllers used to dynamically load theme styles and UI resources.
Properties
commonStyle
var commonStyle: HaapiUIViewControllerStyle
Returns the common style definitions for components used in HaapiUIViewController.
Methods
imageOptional(named:)
func imageOptional(named: String?) -> UIImage?
Returns an image object using the named
image asset. If there is no correspondance thennil
is returned.
- Parameters:
- named: The name of the image asset or file. For images in asset catalogs, specify the name of the image asset. For PNG image files, specify the filename without the filename extension. For all other image file formats, include the filename extension in the name.
- Returns: The
named
image or nil ifnamed
does not exist.
Parameters
Name | Description |
---|---|
named | The name of the image asset or file. For images in asset catalogs, specify the name of the image asset. For PNG image files, specify the filename without the filename extension. For all other image file formats, include the filename extension in the name. |
styleOrThrowFor(stylableType:)
func styleOrThrowFor<U: UIStyle>(stylableType: any UIStylable.Type) throws -> U
Returns the style for an object which conforms to UIStylable
.
- Parameters:
- stylableType: An object which conforms to
UIStylable
.
- stylableType: An object which conforms to
- Throws: Throws an Error such as HaapiError if the style does not exist.
- Returns: A style that is conformed to
UIStyle
for the givenstylableType
.
Parameters
Name | Description |
---|---|
stylableType | An object which conforms to UIStylable . |
styleFor(stylableType:)
func styleFor<U: UIStyle>(stylableType: any UIStylable.Type) -> U
Returns the style for an object which conforms to UIStylable
.
- Parameters:
- stylableType: An object which conforms to
UIStylable
.
- stylableType: An object which conforms to
- Returns: A style that is conformed to
UIStyle
for the givenstylableType
. - Note: If there is no matching
UIStyle
for the given stylableType, then a fatalError is thrown.
Parameters
Name | Description |
---|---|
stylableType | An object which conforms to UIStylable . |
colorOptional(named:)
func colorOptional(named: String?) -> UIColor?
Returns a color object using the named
asset. If the color object is not present in the defined bundle
then it will try to return a color object in the framework bundle. Otherwise, nil
is returned.
- Parameters:
- named: The name of the asset containing the color.
- Returns: The
named
color or anil
ifnamed
does not exist.
Parameters
Name | Description |
---|---|
named | The name of the asset containing the color. |
localizedStringForKey(key:)
func localizedStringForKey(key: String) -> String
Returns a localized string for the given key
.
If the localized string is not present in the app bundle
then it will try to return a localized string in the framework bundle. Otherwise, key
is returned.
- Parameters:
- key: The key for the localized string.
- Returns: The localized string for the given
key
.
Parameters
Name | Description |
---|---|
key | The key for the localized string. |