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
4bef332c
Commit
4bef332c
authored
Jul 07, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added option to adjust tabBar line width
parent
e8ac78ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
5 deletions
+38
-5
Sources/iOS/TabBar.swift
+38
-5
No files found.
Sources/iOS/TabBar.swift
View file @
4bef332c
...
@@ -205,6 +205,12 @@ public enum TabBarCenteringStyle {
...
@@ -205,6 +205,12 @@ public enum TabBarCenteringStyle {
case
always
case
always
}
}
public
enum
TabBarLineStyle
{
case
auto
case
fixed
(
CGFloat
)
case
custom
((
TabItem
)
->
CGFloat
)
}
open
class
TabBar
:
Bar
{
open
class
TabBar
:
Bar
{
/// A dictionary of TabItemLineStates to UIColors for the line.
/// A dictionary of TabItemLineStates to UIColors for the line.
fileprivate
var
lineColorForState
=
[
TabItemLineState
:
UIColor
]()
fileprivate
var
lineColorForState
=
[
TabItemLineState
:
UIColor
]()
...
@@ -243,6 +249,13 @@ open class TabBar: Bar {
...
@@ -243,6 +249,13 @@ open class TabBar: Bar {
}
}
}
}
/// An enum that determines the tab bar items style.
open
var
tabBarLineStyle
=
TabBarLineStyle
.
auto
{
didSet
{
layoutSubviews
()
}
}
/// A reference to the scroll view when the tab bar style is scrollable.
/// A reference to the scroll view when the tab bar style is scrollable.
open
let
scrollView
=
UIScrollView
()
open
let
scrollView
=
UIScrollView
()
...
@@ -486,16 +499,35 @@ fileprivate extension TabBar {
...
@@ -486,16 +499,35 @@ fileprivate extension TabBar {
}
}
guard
shouldNotAnimateLineView
else
{
guard
shouldNotAnimateLineView
else
{
let
f
=
lineFrame
(
for
:
v
,
forMotion
:
true
)
line
.
animate
(
.
duration
(
0
),
line
.
animate
(
.
duration
(
0
),
.
size
(
width
:
v
.
bounds
.
width
,
height
:
lineHeight
),
.
size
(
f
.
size
),
.
position
(
x
:
v
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
lineHeight
/
2
:
lineHeight
/
2
))
.
position
(
f
.
origin
))
return
return
}
}
line
.
frame
=
CGRect
(
x
:
v
.
frame
.
origin
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
lineHeight
:
0
,
width
:
v
.
bounds
.
width
,
height
:
lineHeight
)
line
.
frame
=
lineFrame
(
for
:
v
)
shouldNotAnimateLineView
=
false
shouldNotAnimateLineView
=
false
}
}
func
lineFrame
(
for
tabItem
:
TabItem
,
forMotion
:
Bool
=
false
)
->
CGRect
{
let
y
=
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
(
forMotion
?
lineHeight
/
2
:
lineHeight
)
:
(
forMotion
?
lineHeight
/
2
:
0
)
let
w
:
CGFloat
=
{
switch
tabBarLineStyle
{
case
.
auto
:
return
tabItem
.
bounds
.
width
case
.
fixed
(
let
w
):
return
w
case
.
custom
(
let
closure
):
return
closure
(
tabItem
)
}
}()
let
x
=
forMotion
?
tabItem
.
center
.
x
:
(
tabItem
.
frame
.
origin
.
x
+
(
tabItem
.
bounds
.
width
-
w
)
/
2
)
return
CGRect
(
x
:
x
,
y
:
y
,
width
:
w
,
height
:
lineHeight
)
}
}
}
extension
TabBar
{
extension
TabBar
{
...
@@ -612,9 +644,10 @@ fileprivate extension TabBar {
...
@@ -612,9 +644,10 @@ fileprivate extension TabBar {
selectedTabItem
=
tabItem
selectedTabItem
=
tabItem
let
f
=
lineFrame
(
for
:
tabItem
,
forMotion
:
true
)
line
.
animate
(
.
duration
(
0.25
),
line
.
animate
(
.
duration
(
0.25
),
.
size
(
width
:
tabItem
.
bounds
.
width
,
height
:
lineHeight
),
.
size
(
f
.
size
),
.
position
(
x
:
tabItem
.
center
.
x
,
y
:
.
bottom
==
lineAlignment
?
scrollView
.
bounds
.
height
-
lineHeight
/
2
:
lineHeight
/
2
),
.
position
(
f
.
origin
),
.
completion
({
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
tabItem
=
tabItem
,
completion
=
completion
]
in
.
completion
({
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
tabItem
=
tabItem
,
completion
=
completion
]
in
guard
let
`
self
`
=
self
else
{
guard
let
`
self
`
=
self
else
{
return
return
...
...
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