UIButton
class UIButton : UIControl, NSCoding
This extesion adds some useful functions to UIButton.
-
Create an UIButton in a frame with a title, a background image and highlighted background image.
- Paramters:
- frame: Button frame.
- title: Button title.
- backgroundImage: Button background image.
- highlightedBackgroundImage: Button highlighted background image.
Declaration
Swift
public convenience init(frame: CGRect, title: String, backgroundImage: UIImage? = nil, highlightedBackgroundImage: UIImage? = nil)
- Paramters:
-
Create an UIButton in a frame with a title and a color.
Declaration
Swift
public convenience init(frame: CGRect, title: String, color: UIColor)
Parameters
frame
Button frame.
title
Button title.
color
Button color, the highlighted color will be automatically created.
-
Create an UIButton in a frame with a title, a color and highlighted color.
Declaration
Swift
public convenience init(frame: CGRect, title: String, color: UIColor, highlightedColor: UIColor)
Parameters
frame
Button frame.
title
Button title.
color
Button color.
highlightedColor
Button highlighted color.
-
Create an UIButton in a frame with an image
Declaration
Swift
public convenience init(frame: CGRect, image: UIImage, highlightedImage: UIImage? = nil)
Parameters
frame
Button frame
image
Button image
highlightedImage
Button highlighted image
-
Set the title font with a size.
Declaration
Swift
public func setTitleFont(_ fontName: FontName, size: CGFloat)
Parameters
fontName
Font name from the FontName enum declared in UIFontExtension.
size
Font size.
-
Set the title color.
Declaration
Swift
public func setTitleColor(_ color: UIColor)
Parameters
color
Font color, the highlighted color will be automatically created.
-
Set the title color and highlighted color
Declaration
Swift
public func setTitleColor(_ color: UIColor, highlightedColor: UIColor)
Parameters
color
Button color
highlightedColor
Button highlighted color