UIButton
class UIButton : UIControl, NSCoding
-
Localizing button title
Declaration
Swift
@objc open var localizedTitle: String? { get set }
-
Declaration
Swift
open override func awakeFromNib()
-
Sets the title to use for the specified state. Use this method to set the title for the button. The title you specify derives its formatting from the button’s associated label object. If you set both a title and an attributed title for the button, the button prefers the use of the attributed title over this one. At a minimum, you should set the value for the normal state. If a title is not specified for a state, the default behavior is to use the title associated with the normal state. If the value for normal is not set, then the property defaults to a system value.
Declaration
Swift
@discardableResult @objc open func setLocalizedTitle(_ title: String?, for state: UIControl.State = .normal, fromTableName tableName: String? = nil) -> String?
Parameters
title
The title to localize and use for the specified state.
state
The state that uses the specified title. The possible values are described in UIControlState.
tableName
the .string table name if any
Return Value
the localised title for state
-
Sets the image to use for the specified state. In general, if a property is not specified for a state, the default is to use the normal value. If the normal value is not set, then the property defaults to a system value. Therefore, at a minimum, you should set the value for the normal state.
Declaration
Swift
@objc open func setImage(_ image: UIImage?, withIdentifier identifier: String, for state: UIControl.State = .normal)
Parameters
image
The image to use for the specified state.
identifier
The accessibilityIdentifier used for UITesting
state
The state that uses the specified title. The values are described in UIControlState.
-
Sets the localized button title with format.
Declaration
Swift
@discardableResult open func localizeTitle(formatKey: String, for state: UIControl.State = .normal, _ arguments: CVarArg...) -> String?
Parameters
text
The text to localize
arguments
The arguments to replace
Return Value
the localized placeholder
String?
with format