Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
81909af0
Commit
81909af0
authored
Apr 19, 2019
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added button on and off image support for switch
parent
e56de5fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
Sources/iOS/Switch/Switch.swift
+37
-0
No files found.
Sources/iOS/Switch/Switch.swift
View file @
81909af0
...
@@ -112,6 +112,22 @@ open class Switch: UIControl, Themeable {
...
@@ -112,6 +112,22 @@ open class Switch: UIControl, Themeable {
}
}
}
}
/// Button on image.
@IBInspectable
open
var
buttonOnImage
:
UIImage
?
{
didSet
{
styleForState
(
state
:
switchState
)
}
}
/// Button off image.
@IBInspectable
open
var
buttonOffImage
:
UIImage
?
{
didSet
{
styleForState
(
state
:
switchState
)
}
}
/// Track on color.
/// Track on color.
@IBInspectable
@IBInspectable
open
var
trackOnColor
=
Color
.
clear
{
open
var
trackOnColor
=
Color
.
clear
{
...
@@ -160,6 +176,23 @@ open class Switch: UIControl, Themeable {
...
@@ -160,6 +176,23 @@ open class Switch: UIControl, Themeable {
}
}
}
}
/// Button on disabled image.
@IBInspectable
open
var
buttonOnDisabledImage
:
UIImage
?
{
didSet
{
styleForState
(
state
:
switchState
)
}
}
/// Button off disabled image.
@IBInspectable
open
var
buttonOffDisabledImage
:
UIImage
?
{
didSet
{
styleForState
(
state
:
switchState
)
}
}
/// Track view reference.
/// Track view reference.
open
fileprivate
(
set
)
var
track
:
UIView
{
open
fileprivate
(
set
)
var
track
:
UIView
{
didSet
{
didSet
{
...
@@ -416,9 +449,11 @@ fileprivate extension Switch {
...
@@ -416,9 +449,11 @@ fileprivate extension Switch {
if
.
on
==
state
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnColor
button
.
backgroundColor
=
buttonOnColor
track
.
backgroundColor
=
trackOnColor
track
.
backgroundColor
=
trackOnColor
button
.
image
=
buttonOnImage
}
else
{
}
else
{
button
.
backgroundColor
=
buttonOffColor
button
.
backgroundColor
=
buttonOffColor
track
.
backgroundColor
=
trackOffColor
track
.
backgroundColor
=
trackOffColor
button
.
image
=
buttonOffImage
}
}
}
}
...
@@ -430,9 +465,11 @@ fileprivate extension Switch {
...
@@ -430,9 +465,11 @@ fileprivate extension Switch {
if
.
on
==
state
{
if
.
on
==
state
{
button
.
backgroundColor
=
buttonOnDisabledColor
button
.
backgroundColor
=
buttonOnDisabledColor
track
.
backgroundColor
=
trackOnDisabledColor
track
.
backgroundColor
=
trackOnDisabledColor
button
.
image
=
buttonOnDisabledImage
}
else
{
}
else
{
button
.
backgroundColor
=
buttonOffDisabledColor
button
.
backgroundColor
=
buttonOffDisabledColor
track
.
backgroundColor
=
trackOffDisabledColor
track
.
backgroundColor
=
trackOffDisabledColor
button
.
image
=
buttonOffDisabledImage
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment