SPButton Class Reference
| Inherits from | SPDisplayObjectContainer : SPDisplayObject : SPEventDispatcher : NSObject |
| Declared in | SPButton.h |
Overview
An SPButton is a simple button composed of an image and, optionally, text.
You can pass a texture for up- and downstate of the button. If you do not provide a down state, the button is simply scaled a little when it is touched.
In addition, you can overlay a text on the button. To customize the text, almost the same options
as those of SPTextField are provided. In addition, you can move the text to a certain position
with the help of the textBounds property.
To react on touches on a button, there is special event type: SPEventTypeTriggered. Use
this event instead of normal touch events - that way, the button will behave just like standard
iOS interface buttons.
Tasks
Initialization
-
– initWithUpState:downState:Initializes a button with textures for up- and down-state. Designated Initializer.
-
– initWithUpState:text:Initializes a button with an up state texture and text.
-
– initWithUpState:Initializes a button only with an up state.
-
+ buttonWithUpState:downState:Factory method.
-
+ buttonWithUpState:text:Factory method.
-
+ buttonWithUpState:Factory method.
Properties
-
scaleWhenDownThe scale factor of the button on touch. Per default, a button with a down state texture won’t scale.
property -
alphaWhenDisabledThe alpha value of the button when it is disabled.
property -
enabledIndicates if the button can be triggered.
property -
textThe text that is displayed on the button.
property -
fontNameThe name of the font displayed on the button. May be a system font or a registered bitmap font.
property -
fontSizeThe size of the font.
property -
fontColorThe color of the font.
property -
upStateThe texture that is displayed when the button is not being touched.
property -
downStateThe texture that is displayed while the button is touched.
property -
textBoundsThe bounds of the textfield on the button. Allows moving the text to a custom position.
property -
isDownIndicates if the button is currently being pressed.
property -
colorThe color of the button’s state image. Just like every image object, each pixel’s color is multiplied with this value.
property
Properties
alphaWhenDisabled
The alpha value of the button when it is disabled.
@property (nonatomic, assign) float alphaWhenDisabledDiscussion
The alpha value of the button when it is disabled.
Declared In
SPButton.hcolor
The color of the button’s state image. Just like every image object, each pixel’s color is multiplied with this value.
@property (nonatomic, assign) uint colorDiscussion
The color of the button’s state image. Just like every image object, each pixel’s color is multiplied with this value.
Declared In
SPButton.hdownState
The texture that is displayed while the button is touched.
@property (nonatomic, strong) SPTexture *downStateDiscussion
The texture that is displayed while the button is touched.
Declared In
SPButton.henabled
Indicates if the button can be triggered.
@property (nonatomic, assign) BOOL enabledDiscussion
Indicates if the button can be triggered.
Declared In
SPButton.hfontColor
The color of the font.
@property (nonatomic, assign) uint fontColorDiscussion
The color of the font.
Declared In
SPButton.hfontName
The name of the font displayed on the button. May be a system font or a registered bitmap font.
@property (nonatomic, copy) NSString *fontNameDiscussion
The name of the font displayed on the button. May be a system font or a registered bitmap font.
Declared In
SPButton.hfontSize
The size of the font.
@property (nonatomic, assign) float fontSizeDiscussion
The size of the font.
Declared In
SPButton.hisDown
Indicates if the button is currently being pressed.
@property (nonatomic, readonly) BOOL isDownDiscussion
Indicates if the button is currently being pressed.
Declared In
SPButton.hscaleWhenDown
The scale factor of the button on touch. Per default, a button with a down state texture won’t scale.
@property (nonatomic, assign) float scaleWhenDownDiscussion
The scale factor of the button on touch. Per default, a button with a down state texture won’t scale.
Declared In
SPButton.htext
The text that is displayed on the button.
@property (nonatomic, copy) NSString *textDiscussion
The text that is displayed on the button.
Declared In
SPButton.hClass Methods
buttonWithUpState:
Factory method.
+ (instancetype)buttonWithUpState:(SPTexture *)upStateDiscussion
Factory method.
Declared In
SPButton.hInstance Methods
initWithUpState:
Initializes a button only with an up state.
- (instancetype)initWithUpState:(SPTexture *)upStateDiscussion
Initializes a button only with an up state.
Declared In
SPButton.hinitWithUpState:downState:
Initializes a button with textures for up- and down-state. Designated Initializer.
- (instancetype)initWithUpState:(SPTexture *)upState downState:(SPTexture *)downStateDiscussion
Initializes a button with textures for up- and down-state. Designated Initializer.
Declared In
SPButton.h